I have a change password page in my app, so users can change their password. This page was working fine a few days ago, and I'm not sure what I changed, but now it is giving me validation errors. (outlined below)
Here are my pages:
user.rb
user_controller.rbCode:validates_confirmation_of :password validates_length_of :password, :minimum => 6
user/changepass.rhtmlCode:def changepass if request.post? #form submitted @user.update_attributes(params[:user]) if @user.save flash[:notice] = "Password Successfully Changed" end end end
When I leave the textfields blank I get:Code:<form id="changepass" action="" method="post"> <fieldset> <legend>New Password</legend> <label for="user_password">New Password:</label><%= password_field("user", "password")%> <label for="user_password_confirmation">Confirm Password:</label><%= password_field("user", "password_confirmation", {:value => ""}) %> <input type="submit" class="submit" value=" Change Password "/> </form>
1 error, --> Password must be at least 6 characters.
When I put in a 6+ character password in both boxes (they match):
2 errors --> Password must be at least 6 characters and Password confirmation does not match password.
I do have a before_create method, in user.rb, that auto-assigns a password for when the account is created, could this be the problem? I would think that would only get called on a new user, not updating a current one.
Any ideas?




Bookmarks