mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Setup on_encrypted_attribute_declared hook only once
This commit is contained in:
parent
3da45ea10e
commit
c9eb8c44f4
3 changed files with 4 additions and 4 deletions
|
@ -50,7 +50,7 @@ module ActiveRecord
|
|||
end
|
||||
end
|
||||
|
||||
def install_auto_filtered_parameters(application) # :nodoc:
|
||||
def install_auto_filtered_parameters_hook(application) # :nodoc:
|
||||
ActiveRecord::Encryption.on_encrypted_attribute_declared do |klass, encrypted_attribute_name|
|
||||
application.config.filter_parameters << encrypted_attribute_name unless ActiveRecord::Encryption.config.excluded_from_filter_parameters.include?(name)
|
||||
end
|
||||
|
|
|
@ -360,9 +360,9 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|||
end
|
||||
|
||||
# Filtered params
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
ActiveSupport.on_load(:action_controller, run_once: true) do
|
||||
if ActiveRecord::Encryption.config.add_to_filter_parameters
|
||||
ActiveRecord::Encryption.install_auto_filtered_parameters(app)
|
||||
ActiveRecord::Encryption.install_auto_filtered_parameters_hook(app)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ class ActiveRecord::Encryption::ConfigurableTest < ActiveRecord::EncryptionTestC
|
|||
|
||||
test "install autofiltered params" do
|
||||
application = OpenStruct.new(config: OpenStruct.new(filter_parameters: []))
|
||||
ActiveRecord::Encryption.install_auto_filtered_parameters(application)
|
||||
ActiveRecord::Encryption.install_auto_filtered_parameters_hook(application)
|
||||
|
||||
Class.new(Pirate) do
|
||||
self.table_name = "pirates"
|
||||
|
|
Loading…
Reference in a new issue