Hi,有一个问题请教:
有这么一个 json 文件,里面的格式是这样的
[[{"linkID": ["/watch?v=hjkVdFa3DH8"], "title": ["Chinese electronics industry now uses unique Danish robots"]},
{"linkID": ["/watch?v=RDvgNB2OZxI"], "title": ["RI Seminar: Rodney Brooks : A New Class of Industrial Robot"]},
{"linkID": ["/watch?v=MeFo-yloxdU"], "title": ["Motoman robots in electronic assembly applications"]},
{"linkID": ["/watch?v=-UkVsJFkdZI"], "title": ["Speed test with industrial robot Motoman UP80"]}]
我想把这些数据导入到我的 railsapp 里面去,我想通过 seeds.rb 导入:
records = Video.new(JSON.parse(File.read('youtube.json')))
records.each do |record|
Video.create!(record['linkID'],record['title'])
end
执行 rake db:seed 我查了测试用的 sqlite3 数据库,没有一点反应,请教是哪里有问题了?