我写了一个小的ruby脚本,它生成一个如下所示的数组:
{:title=>"Lorem ipsum",
:category=>["Lorem ipsum"],
:items=>
["Lorem ipsum",
"Lorem ipsum",
"Lorem ipsum"],
:process=>
["Sed ut perspiciatis unde omnis iste natus error."]}
如何运行该脚本以将输出保存到rails数据库中?
答案 0 :(得分:1)
通过一些猜测...你可以写这是一个rake任务:
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")],
})