开发者

Saving the output from a ruby script into my rails database

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")],
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜