tommyd456
tommyd456

Reputation: 10673

Rails Seed Data from file

I'm trying to create some seed data and got this code from Railcasts. I've modified it slightly but doesn't seem to be working when i run bundle exec rake db:seed from the terminal. I get the following error in the terminal...

wrong number of arguments (0 for 1)

Below is my code in the seeds.rb file to populate the table. Is there a silly mistake in there somewhere?

require 'open-uri'

International.delete.all
open("international.txt") do |countries|
  countries.read.each_line do |data|
    code, country, currency = data.chomp.split("|")
    International.create!(:code => code, :country => country, :currency => currency)
  end
end

and my text file (stored in the same directory as the seeds.rb file is...

AU|Australia|AUD
CA|Canada|CAD
GB|United Kingdom|GBP
US|United States|USD

Upvotes: 2

Views: 1421

Answers (1)

Kyle
Kyle

Reputation: 22258

You need to pass an id to delete.

I assume you want to delete_all

International.delete_all

Upvotes: 5

Related Questions