diff options
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 7 | ||||
-rw-r--r-- | activemodel/lib/active_model/secure_password.rb | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 11ebfe6cc0..5219de2606 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -204,7 +204,7 @@ module ActiveModel # extend ActiveModel::Naming # end # - # BookCover.model_name # => "BookCover" + # BookCover.model_name.name # => "BookCover" # BookCover.model_name.human # => "Book cover" # # BookCover.model_name.i18n_key # => :book_cover @@ -218,10 +218,11 @@ module ActiveModel # used to retrieve all kinds of naming-related information # (See ActiveModel::Name for more information). # - # class Person < ActiveModel::Model + # class Person + # include ActiveModel::Model # end # - # Person.model_name # => Person + # Person.model_name.name # => "Person" # Person.model_name.class # => ActiveModel::Name # Person.model_name.singular # => "person" # Person.model_name.plural # => "people" diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 826e89bf9d..4033eb5808 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -52,8 +52,6 @@ module ActiveModel raise end - attr_reader :password - include InstanceMethodsOnActivation if options.fetch(:validations, true) @@ -68,6 +66,7 @@ module ActiveModel validates_confirmation_of :password, if: ->{ password.present? } end + # This code is necessary as long as the protected_attributes gem is supported. if respond_to?(:attributes_protected_by_default) def self.attributes_protected_by_default #:nodoc: super + ['password_digest'] @@ -91,6 +90,8 @@ module ActiveModel BCrypt::Password.new(password_digest) == unencrypted_password && self end + attr_reader :password + # Encrypts the password into the +password_digest+ attribute, only if the # new password is not blank. # |