Form Change Old Password

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 :frowning:

I appreciate any help :smiley:

Rails server is weird, things are not working, when I do changes and put
everything back like it was, it then starts working again??

This is not the first time its happening!