ruby on rails - How to use has_secure_password with field_with_errors -
i using has_secure_password verify user password , confirmation. problem have when there errors, fields not being wrapped field_with_errors div. know can add
validates_presence_of :password, :on => :create validates_presence_of :password_confirmation, :on => :create
but creates following error message:
password digest can't blank.
password can't blank.
password confirmation can't blank
i either make has_secure_password wrap fields errors field_with_errors div or remove "password digest can't blank." error altogether.
thanks.
the securepassword module has functionality quite simple , worth look. news in the master branch (rails 4) validates_presence_of :password, :on => :create
solve problem, in meantime might want mimic has_secure_password
method on user model yourself.
class user < activerecord::base attr_reader :password attr_accessible :password # ... validates_confirmation_of :password validates_presence_of :password, on: :create include activemodel::securepassword::instancemethodsonactivation end
also make sure bcrypt
loaded in gemfile.
gem 'bcrypt-ruby', '~> 3.0.0', require: 'bcrypt'
hope helps.
Comments
Post a Comment