Forum: Ruby on Rails Migration ~ Create

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9904f8acaf66a3c1a4b4434676be11cf?d=identicon&s=25 John Kopanas (Guest)
on 2006-03-21 19:01
(Received via mailing list)
In one of my migration files I have the following:

===========
   def self.up
     User.create :name => 'John Kopanas', :email =>
'john@kopanas.com', :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. :-)

Your Friend

John Kopanas
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-03-21 19:10
(Received via mailing list)
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
9904f8acaf66a3c1a4b4434676be11cf?d=identicon&s=25 John Kopanas (Guest)
on 2006-03-21 19:28
(Received via mailing list)
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 Maddox wrote:

>
>>
>> ===========
>>
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails


John Kopanas
This topic is locked and can not be replied to.