# Devise :current\_password validations and checking (how?)

**URL:** <https://www.ruby-forum.com/t/devise-current-password-validations-and-checking-how/192962>\
**Category:** Rails\
**Created:** [August 9, 2010, 9:17am UTC](https://www.ruby-forum.com/t/devise-current-password-validations-and-checking-how/192962 "2010-08-09T09:17:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@drec](https://www.ruby-forum.com/u/drec)\
**Post date:** [August 9, 2010, 9:17am UTC](https://www.ruby-forum.com/t/devise-current-password-validations-and-checking-how/192962/1 "2010-08-09T09:17:45Z")

</div>

Hi Guys,

In my devise applications in Rails 3, I created a separate form under my  
SettingsController class of which it handles the ‘Change Password’ of  
the User Model, so i can manipulate the current\_user in the  
SettingsController.

Now, I followed the set-up in the Devise/Views on how to update the form  
using ‘Change password’ and either way update User for current\_password  
change but I’ve no luck on the implementation. I need you experties

My question is, how to check the my :current\_password to the  
params[:user][:current\_password] I tried to submit in the form. Meaning  
how can the devise check the submitted params[:user][:current\_password]  
to match and validate on the current\_user.pasword

This is my code, i’m using HAML  
I’m also using config.encryptor = :restful\_authentication\_sha1  
since I migrated from auth\_logic to devise authentication tool

“Views/Settings/change\_password.haml” goes like this

* * *

%aside#sidebar  
%nav.leftbar  
%ul  
%li.pwd= link\_to “Password”, change\_password\_path

%section#content.w.r  
= form\_for(@user, :as =\> :user, :url =\> change\_password\_path(:user))  
do |f|  
%h1 Change your password  
%fieldset  
%div  
= f.hidden\_field :reset\_password\_token  
%div  
= f.label :current\_password  
= f.password\_field :current\_password, :autofocus =\> true  
%div  
= f.label :password  
= f.password\_field :password  
%div  
= f.label :password\_confirmation  
= f.password\_field :password\_confirmation

```
  .action
    = f.submit "Change password"
    or
    = link_to "Cancel", settings_path

```

* * *

“SettingsController” goes like this below using change\_password method

* * *

def change\_password  
if params[:user]  
begin  
current\_user.update\_attributes!(:password =\>  
params[:user][:password])  
flash[:notice] = “Password successfully changed”  
redirect\_to settings\_path  
rescue Exception =\> msg  
flash[:notice] = msg  
end  
else  
@user = current\_user  
end  
end

* * *
