Keith Bachand Keith Bachand - 1 month ago 9
Git Question

Getting CSV files to work on Heroku rails app

I am trying to import ailments.csv to work on Heroku and its just not wanting to work properly. I have searched and searched with no real solutions.

Locally it is working fine and the ailments show.

Here is the Heroku app link so you can see what I'm having issues with.
https://sleepy-garden-73993.herokuapp.com/

HOW TO GET TO AILMENTS:
-Click on "check your address"
-Enter 202 tryon st for address, and 28207 for zip code (This is within our service area)
-There will be a dropdown that says select your ailment. And you can see its blank. It should be displaying the ailments within the csv file.

LINK TO GITHUB REPO:
https://github.com/kbachand/ginger_ails

Its too much code to post on here so it will be easier for you to see how I've done things on the github repo.

Import rake code

require 'csv'
namespace :import_ailment do
desc "Import ailment from a CSV file"
task ailments: :environment do
CSV.foreach("ailments.csv") do |row|
name, description, shopping_list, price = row
Ailment.create(name: name, description: description, shopping_list: shopping_list, price: price)
end
end
end

Answer

Make sure you run the migration on Heroku with:

heroku run rake import_ailment:ailments
Comments