# Login authenticate?

**URL:** <https://www.ruby-forum.com/t/login-authenticate/87417>\
**Category:** Rails\
**Created:** [March 2, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/login-authenticate/87417 "2007-03-02T13:23:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [March 2, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/login-authenticate/87417/1 "2007-03-02T13:23:19Z")

</div>

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:

if request.post?  
@user = User.authenticate(params[:user][:email],  
params[:user][:password])  
if @user  
redirect\_to :action =\> ‘my\_account’  
end  
end

This is how the model authenticate look like.

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

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.

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [March 2, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/login-authenticate/87417/2 "2007-03-02T16:18:34Z")

</div>

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.
