我有一个种子.rb 文件,其中包含要播种的数据。并非所有数据都被播种并以终端中rake db:seed
的消息结尾killed
。但是,同样适用于开发环境。这是我想要播种的部分
xls_utility = Roo::Spreadsheet.open('/path/to/data.xlsx')
utilities = []
xls_utility.each do |row|
utility = Utility.new
if row[0] != "State"
["state_code", "value"].each_with_index do |attribute, index|
utility[attribute] = row.flatten[index]
end
utilities << utility
end
end
Utility.import utilities