Ruby on Rails Saturday, October 30, 2010

I found this thread while searching for how to validate a string as a
user's password in the controller, and was disappointed when I didn't
find the answer.

I figured it out so I figured I'd post the answer for other people that
do the same thing.

The User model get's a method valid_password? with :acts_as_authentic.
So to test the password you would just do:

@current_user.valid_password? params[:old_password]

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment