I am using has_secure_password to verify my user password and its confirmation. The problem I have is that when there are any errors, the fields are not being wrapped with a field_with_errors div. I know that I can add
validates_presence_of :password, :on => :create
validates_presence_of :password_confirmation, :on => :create
but that creates the following error message:
Password digest can’t be blank.
Password can’t be blank.
Password confirmation can’t be blank
I would like to either make the has_secure_password wrap the fields with errors with a field_with_errors div or remove the “Password digest can’t be blank.” error altogether.
Thanks.
The SecurePassword module which has this functionality is quite simple and worth a look. Good news is that in the master branch (Rails 4) it does
validates_presence_of :password, :on => :createwhich will solve your problem, but in the meantime you might want to mimic thehas_secure_passwordmethod on the User model yourself.Also make sure
bcryptis loaded in Gemfile.Hope that helps.