From 9eb15ed6a08f76ef683bb10a84f824b9dc379e3a Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Wed, 2 Jul 2014 14:39:41 -0700 Subject: Only automatically include validations when enabled This is a follow up to #16024. --- activemodel/lib/active_model/secure_password.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index 88e578e626..7e179cf4b7 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -1,7 +1,6 @@ module ActiveModel module SecurePassword extend ActiveSupport::Concern - include ActiveModel::Validations # BCrypt hash function can handle maximum 72 characters, and if we pass # password of length more than 72 characters it ignores extra characters. @@ -65,6 +64,8 @@ module ActiveModel include InstanceMethodsOnActivation if options.fetch(:validations, true) + include ActiveModel::Validations + # This ensures the model has a password by checking whether the password_digest # is present, so that this works with both new and existing records. However, # when there is an error, the message is added to the password attribute instead -- cgit v1.2.3