1.Create a folder inside of lib
called seeds
2. Put your CSV file example.csv
into the lib/seeds
folder.
3.
#model needs to already exist in the DB, even if no instances
require 'csv'
csv_text = File.read(Rails.root.join('lib', 'seeds', 'file.csv'))
csv = CSV.parse(csv_text, :headers => true, :encoding => 'UTF-8')
csv.each do |row|
m = Model.new
m.field = row.field
m.save
end