instance method
hash_filter
Ruby on Rails 4.1.16
Since v4.0.13 PrivateSignature
hash_filter(params, filter)
No documentation comment.
Parameters
-
paramsreq -
filterreq
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 447
def hash_filter(params, filter)
filter = filter.with_indifferent_access
# Slicing filters out non-declared keys.
slice(*filter.keys).each do |key, value|
next unless value
if filter[key] == EMPTY_ARRAY
# Declaration { comment_ids: [] }.
array_of_permitted_scalars_filter(params, key)
else
# Declaration { user: :name } or { user: [:name, :age, { address: ... }] }.
params[key] = each_element(value) do |element|
if element.is_a?(Hash)
element = self.class.new(element) unless element.respond_to?(:permit)
element.permit(*Array.wrap(filter[key]))
end
end
end
end
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 447
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters