As per this example, the following method:
require "csv"
def import_vault_data(filename)
fn = "#{RAILS_ROOT}/public/data/#{filename}"
CSV.foreach(fn, :headers => true) do |row|
House.create!(row.to_hash)
end
end
is producing this error:
undefined method `to_hash' for #<Array:0x104cc07b8>
Any clue as to what is missing?
I am using rails 2.3.9
try this for ruby 1.8.7
House.create!(row.hash)