On Feb 6, 5:18 pm, Kelly Pfaff <[email protected]> wrote: > Hi, > Im trying to make an application based on the 'depot' app from 'Agile > web development with Rails'. Instead of putting the data in > add_test_data.rb itself (p.89), I want to read it in from a txt file > like this (gg.txt has a list of front and last names): > > class AddTestData < ActiveRecord::Migration > def process(k) > k.chop! > ary = k.split > Zwemmer.create(:lastname => ary[1,3].join(' '), :frontname => > ary[0].to_s.downcase, :group => 'gg', :image_url => '/images/ggs.png') > end > > def self.up > Zwemmer.delete_all > myfile =File.new("gg.txt", "r") > myfile.each {|line| process(line)} > myfile.close > end > > def self.down > end > end > > error: > rake aborted! > No such file or directory - gg.txt > > gg.txt is in the same directory as add_test_data.rb. Where should i put > the txt file? How should i read it in?
Rake sets the work directory to the root of the rails app. You're also trying to call an instance method from a class method, which won't work. Fred > > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

