I'm trying to import a csv file to a ruby on rails app database. I got this error unknown attribute '2191' for Landslide.
when running bundle exec rake db:import_csv
. 2191 is the first item on the first row of the csv file.
import_csv.rake
require 'csv'
namespace :db do
task :import_csv => :environment do
CSV.foreach("Sample_landslides.csv", :headers => true) do |row|
Landslide.create!(row.to_hash)
end
end
end
schema
create_table "landslides", force: :cascade do |t|
t.integer "total_id"
t.integer "year_id"
t.date "start_date"
t.date "end_date"
t.integer "day_number"
t.string "continent"
t.string "country"
t.string "location"
t.string "type"
t.integer "admin_level"
t.float "lat"
t.float "lng"
t.boolean "mapped"
t.float "spatial_area"
t.integer "fatalities"
t.integer "injuries"
t.string "notes"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "trigger"
end