I wrote a small ruby script that generates an array like the one below:
{:title=>"Lorem ipsum",
:category=>["Lorem ipsum"],
:items=>开发者_如何学JAVA;
["Lorem ipsum",
"Lorem ipsum",
"Lorem ipsum"],
:process=>
["Sed ut perspiciatis unde omnis iste natus error."]}
How can I run that script in order to save the output into my rails database?
With a bit of guessing... you can write this is a rake task:
WeDontKnowWhichModelHere.create!({
:title => "Lorem ipsum",
:categories => [Category.new(:name => "Lorem ipsum"), ...],
:items => [Item.new(:name => "Lorem ipsum"), ...],
:processes => [Process.new(:name => "Sed ut perspiciatis unde omnis iste natus error")],
})
精彩评论