Blankman
Blankman

Reputation: 266940

user.find(1) results in an exception, is my system ok or my setup is messed up?

My database is empty, and I understand that I should get an exception.

Just want to make sure that my macbookpro is setup with rails properly.

typing:

user.find(1)

in console I get:

>> user.find(1)
NoMethodError: undefined method `find' for #<User:0x1016403a0>
    from /Library/Ruby/Gems/1.8/gems/activemodel-3.0.0/lib/active_model/attribute_methods.rb:364:in `method_missing'
    from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/attribute_methods.rb:46:in `method_missing'
    from (irb):25
>> 

I am using rails 3.0, with ruby 1.8.7

Upvotes: 1

Views: 156

Answers (1)

sepp2k
sepp2k

Reputation: 370102

According to the message user is an instance of the User class. Since there is no instance method find for AR objects (unless you defined it yourself), it's perfectly normal that you get a NoMethodError.

You probably intended to call User.find(1) (capital U).

Upvotes: 8

Related Questions