更新时间:2022-10-14 23:30:59
我认为这是一个更好,更优雅的方式:
user = User.find_by_email(params [:user] [:email])
user.valid_password?(params [:user] [:password])
从用户实例生成摘要的其他方法是给我保护方法错误。
I'm having a problem matching user password using devise gem in rails. User password stored on my db which is encrypted_password and i am trying to find user by password, but I don't understand how to match password from form and encrypted_password in my db.
User.find_by_email_and_password(params[:user][:email], params[:user][:password])
I think this is a better, and more elegant way of doing it:
user = User.find_by_email(params[:user][:email])
user.valid_password?(params[:user][:password])
The other method where you generate the digest from the user instance was giving me protected method errors.