Migration ~ Create


In one of my migration files I have the following:

def self.up
User.create :name => ‘John K.’, :email =>
‘removed_email_address@domain.invalid’, :password => ‘test’

When I run it I get the following error:

undefined method `create’ for

When I copy the line and paste it in console it works perfectly.
Even using the longer method of

user = User.new

Does not work in the migration. Tells me method name does not
exist. It exists.

Anyone have any insight about this. Problem has been driving me
crazy for the last 30 minutes. :slight_smile:

Your Friend

John K.


Try putting

class User < ActiveRecord::Base; end;

In your migration. I forget if it needs to go inside or outside the
migration class (I’d think inside), so if one doesn’t work, give the
other one a shot.



I even started getting some funny errors like

superclass mismatch for class User

I ended up deleting the user model and migration files and started
again and it worked perfectly.


On 21-Mar-06, at 1:07 PM, Pat M. wrote:


Rails mailing list

John K.