Created
October 26, 2013 19:19
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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