Migration ~ Create


#1

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’
end

When I run it I get the following error:

===========
undefined method `create’ for
#ActiveRecord::ConnectionAdapters::MysqlAdapter:0x2345c1c

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

===========
user = User.new
user.name
user.save

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.


#2

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.

Pat


#3

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.

Thanks

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

===========

Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

John K.