Skip to content

Instantly share code, notes, and snippets.

@chadjemmett
Created October 26, 2013 19:19
Show Gist options
  • Save chadjemmett/7173459 to your computer and use it in GitHub Desktop.
Save chadjemmett/7173459 to your computer and use it in GitHub Desktop.
So this will get csv data into a rails database. I just did it from the console. But you could make it a rake task. the headers in the csv file have to match the model attributes attr_accessor variables.
require 'csv'
CSV.foreach(filename, :headers => true) do |row|
Pokemon.create!(row.to_hash)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment