Forum: Ruby on Rails Login authenticate?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E3513c4edd6810bb4b9914b58da2a2c3?d=identicon&s=25 Jamal Soueidan (jamal)
on 2007-03-02 13:23
Hello there,

I'm trying to do the login section for my small web application, but it
doesn't seem to work like I want.

Here is the Controller:

    @user = User.authenticate(params[:user][:email],
    if @user
      redirect_to :action => 'my_account'

This is how the model authenticate look like.

  def self.authenticate(email, password)
    @user = User.find(  :first,
              :conditions => ["email = ? and password = ?", email,
              :limit => 1);
    return false if @user.nil?
    return true if @user

But whenever I try to login I get a error

undefined method `email' for false:FalseClass

I don't know what this one means? could anyone help me and Thanks for
Your help.
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-03-02 16:18
(Received via mailing list)
are you seeing this error on the 'login page' or the my 'account page'

my guess is that since you are returning @user as true/false, your
authenticate is not working correctly, and is returning false, so the
login form gets redisplayed, which is expecting @user to be a valid
User object so it can populate the forms.

I could be more certain if i was able to see your entire controller
method (login?) and your login view.
This topic is locked and can not be replied to.