Hello there,
I want my users to be able to change their password.
I wrote the code below but I need help to add error if the old password
he posted did not match the current password he have.
In the controller I have:
def my_profile_password
return true unless request.post?
@user = current_user
if @user.check_password(params[:old_password])
@user.update_attributes(params[:user])
if @user.update
end
end
end
and in my model:
def check_password(password)
if self.password == User.encrypt(password)
true
end
end
PS: I know I should use @user.errors.add("", "Old password is
wrong"),
but where should I place it in my code?
I tried within check_password but this is not working :(
I appreciate any help :D
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---