Take the 2-minute tour ×

Well, I having a problem with matches user password in devise rails. User password store on my db which encrypted_password and when I trying find user by password, I don't understand how match password from form and encrypted_password in my db.

User.find_by_email_and_password(params[:user][:email], params[:user][:password])
share|improve this question
I think the correct answer has been offered up. Can you select it? –  Brendon Muir Apr 8 '13 at 4:25
add comment

2 Answers

I think this is a better, and more elegant way of doing it:

user = User.find_by_email(params[:user][:email])

The other method where you generate the digest from the user instance was giving me protected method errors.

share|improve this answer
+1, password_digest give me protected method error as well –  Adrian Serafin Mar 5 '11 at 10:16
password digest is protected, you can get around it this way. User.new.send(:password_digest, 'password') –  Swards Oct 27 '13 at 6:25
add comment


share|improve this answer
that's not absolutely what I want. Another words, I can't encrypt user password for match with encrypted_password in my db. –  Popo Dec 1 '10 at 3:56
add comment

Your Answer


