I want to import data from a csv file into my database in rails. The model to which I want to import data is:
create_table "clubs", force: true do |t|
t.text "club"
t.text "location"
t.text "address"
t.text "description"
t.string "email"
t.string "phone"
t.datetime "created_at"
t.datetime "updated_at"
t.string "photo_file_name"
t.string "photo_content_type"
t.integer "photo_file_size"
t.datetime "photo_updated_at"
t.string "city"
t.float "latitude"
t.float "longitude"
end
In the csv file I have data for 'club', 'location', 'address', 'email', 'phone' and 'city', but it is possible that for some rows the data of any of the above mentioned attributes might be missing.
So, can anyone help me how to migrate the data from this csv file in database using rake task?
Thanks in advance.