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
@user = current_user
if @user.check_password(params[:old_password])
if @user.update

and in my model:
def check_password(password)
if self.password == User.encrypt(password)

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!