From 9caf8ddb93cd8bf77dfaa2e60dd8c1c24b881f94 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 2 Oct 2020 13:03:54 +0900 Subject: [PATCH] *_ditest and *_digest= are defined as public methods --- activemodel/lib/active_model/secure_password.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activemodel/lib/active_model/secure_password.rb b/activemodel/lib/active_model/secure_password.rb index c177d771ad..a385e837c6 100644 --- a/activemodel/lib/active_model/secure_password.rb +++ b/activemodel/lib/active_model/secure_password.rb @@ -79,7 +79,7 @@ module ActiveModel # when there is an error, the message is added to the password attribute instead # so that the error message will make sense to the end-user. validate do |record| - record.errors.add(attribute, :blank) unless record.send("#{attribute}_digest").present? + record.errors.add(attribute, :blank) unless record.public_send("#{attribute}_digest").present? end validates_length_of attribute, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED @@ -94,11 +94,11 @@ module ActiveModel define_method("#{attribute}=") do |unencrypted_password| if unencrypted_password.nil? - self.send("#{attribute}_digest=", nil) + self.public_send("#{attribute}_digest=", nil) elsif !unencrypted_password.empty? instance_variable_set("@#{attribute}", unencrypted_password) cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost - self.send("#{attribute}_digest=", BCrypt::Password.create(unencrypted_password, cost: cost)) + self.public_send("#{attribute}_digest=", BCrypt::Password.create(unencrypted_password, cost: cost)) end end