small medium large xlarge

Generic-user-small
02 Aug 2008, 13:26
David Hallman (1 post)

I’m new to rails programming so, I’m probably missing something simple.

I’ve got a simple application talking with MySQL. My application actually starts just fine using the database name, username, and password for the database. I can also use the console to create new objects (in my case Program.create(…)) with no problem. When I do migrations table creation calls also work. I didn’t install InstantRails like the book. I was following along with how to load data in the sample app.

The problem I’m encountering is when I do a migrate (rake db:migrate) with create and/or delete_all calls. I get an undefined method error. I assumed the basic rake was working since it was creating my tables.

Here is a sample of a migration file that fails (undefined method on the Program.delete_all):

` class ProgramsLoad < ActiveRecord::Migration def self.up

Program.delete_all
#Program.create(:name => 'Program 1',
# :description => 'Program 1 description')

end

def self.down #Program.delete_all end end `

Like I said, these commands work when in the console (script/console).

Thoughts? Any help would be appreciated.

-Dave

Generic-user-small
04 Aug 2008, 09:08
James West (104 posts)

Hi, I havent’t analysed your code fully (I’m not that good with RoR yet) but it looks like you have the code in the up and down methods the wrong way round. Up shouls create and down should delete. I think! lol :-) Good luck

You must be logged in to comment