Forum: Ruby on Rails Form Change Old Password

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jamal S. (Guest)
on 2007-05-31 14:12
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 :(

I appreciate any help :D
Jamal S. (Guest)
on 2007-05-31 14:23
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!
This topic is locked and can not be replied to.