From 2df8e86caf35d6f85d6b4fe260ddd247bbe6772a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 17 Jul 2015 13:32:10 -0700 Subject: stop passing `params` to `array_of_permitted_scalars_filter` this way the method doesn't have to know what the new params object is, it just yields to a block. This change also caches the value of `self[key]` on the stack --- actionpack/lib/action_controller/metal/strong_parameters.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/metal') diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index a989641cdb..03639c1835 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -648,9 +648,9 @@ module ActionController end end - def array_of_permitted_scalars_filter(params, key) - if array_of_permitted_scalars?(self[key]) - params[key] = self[key] + def array_of_permitted_scalars_filter(value) + if array_of_permitted_scalars?(value) + yield value end end @@ -665,7 +665,9 @@ module ActionController if filter[key] == EMPTY_ARRAY # Declaration { comment_ids: [] }. - array_of_permitted_scalars_filter(params, key) + array_of_permitted_scalars_filter(self[key]) do |val| + params[key] = val + end else # Declaration { user: :name } or { user: [:name, :age, { address: ... }] }. params[key] = each_element(value) do |element| -- cgit v1.2.3