Reputation: 185
I'm trying to have this url place everything in the csv into my database.
here is the code i have so far
require 'open-uri'
namespace populate do
task reload: :environment do
Afftable.delete_all
url = 'something.com/format=csv'
CSV.open(url).each do |row|
Afftable.create(name: row[0], address: row[1])
end
end
end
When i try running this command i get this error
Command: bundle exec rake populate:reload
Error: NameError: undefined local variable or method
populate' for main:Object`
My database has all the headers in the csv file already inside the database. (i've not touched the create yet as i don't really know what im doing with this)
Upvotes: 0
Views: 40
Reputation: 541
I think that you need a colon in front of populate.
namespace :populate do
Upvotes: 2