diff options
author | Michael de Silva <michael@mwdesilva.com> | 2012-03-11 23:31:11 +0300 |
---|---|---|
committer | Michael de Silva <michael@mwdesilva.com> | 2012-03-11 23:31:37 +0300 |
commit | ddbea9474e20a40e80110944c1e3493ba0efe572 (patch) | |
tree | 45486ce19e3b064cbd1bf275ab71fd8831218ff1 /activemodel/lib/active_model/secure_password.rb | |
parent | 625cb12f21d08630577047ccf11678f886145234 (diff) | |
download | rails-ddbea9474e20a40e80110944c1e3493ba0efe572.tar.gz rails-ddbea9474e20a40e80110944c1e3493ba0efe572.tar.bz2 rails-ddbea9474e20a40e80110944c1e3493ba0efe572.zip |
Fixed Issue #2884 ActiveModel::SecurePassword code / rdoc conflict; an elucidated explanation has been provided and ActiveModel en-locale updated to present a less confusing attribute name for 'password_digest' in form errors due to "has_secure_password"
Diffstat (limited to 'activemodel/lib/active_model/secure_password.rb')
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index e7a57cf691..7c529cb67b 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -10,6 +10,19 @@ module ActiveModel # a "password_confirmation" attribute) are automatically added. # You can add more validations by hand if need be. # + # Note: the implementation of <tt>has_secure_password</tt> enforces presence validation + # on the <tt>:password_digest</tt> attribute rather than on <tt>:password</tt>, which is + # in fact a virtual reader attribute. However, <tt>validates_confirmation_of</tt> ensures + # an indirect means of presence validation of <tt>:password</tt> if the + # <tt>:password_confirmation</tt> attribute is not nil. + # + # You may want to add presence validation on <tt>:password</tt> for the benefit of your forms + # + # class User < ActiveRecord::Base + # has_secure_password + # validates :password, :presence => { :on => :create } + # end + # # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use has_secure_password: # # gem 'bcrypt-ruby', '~> 3.0.0' |