Frederiko Costa wrote in post #1024504: > def authenticate(email, submitted_password) > user = find_by_email(email) > #user = where(:email => email).first > (user && user.has_password?(submitted_password)) ? user : nil > end > > in the authenticate method, the find_by_id(id) call is returning nil. > Going > to the console, the function is not available to me whenever I call it. > The
If you have: user = find_by_id(id) What part of that statement is the receiver of the message "find_by_id"? I think you meant: user = User.find_by_id(id) So to answer my own question, the receiver in this case is the class User, which means that find_by_id is a class method as opposed to an instance method. And, just to be clear, the method "find_by_id" is what is called a "dynamic finder" method. It actually doesn't exist until the first time it is called. The method will be dynamically added to the receiving class (User in this case) via the method_missing method that all Ruby objects respond to. http://blog.hasmanythrough.com/2006/8/13/how-dynamic-finders-work -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

