即使命令提示符位于lib/tasks目录中,当给定命令rake populate时,它也会简单地响应“没有这样的文件或目录”
目录结构
库/任务
种子耙
类型.csv
文件
种子.rake:
task :populate do
require 'csv'
CSV.foreach('type.csv', headers: true) do |row|
puts line
end
end
类型.csv:
"26","Accessories"
"24","Activ8"
"17","Bandages"
"29","Biohazard"
"1","BS8599-1 First Aid Kits"