开发者

Saving the output from a ruby script into my rails database

开发者 https://www.devze.com 2023-02-05 04:02 出处:网络
I wrote a small ruby script that generates an array like the one below: {:title=>\"Lorem ipsum\", :category=>[\"Lorem ipsum\"],

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

精彩评论

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