remove useless conditionals
`element` can never be a hash because: 1. `slice` returns a Parameters object and calls each on it:cb3f25593b/actionpack/lib/action_controller/metal/strong_parameters.rb (L656)
2. `each` which is implemented by `each_pair` will call `convert_hashes_to_parameters` on the value:cb3f25593b/actionpack/lib/action_controller/metal/strong_parameters.rb (L192-197)
3. `convert_hashes_to_parameters` will convert any hash objects in to parameters objects:cb3f25593b/actionpack/lib/action_controller/metal/strong_parameters.rb (L550-566)
This commit is contained in:
parent
cb3f25593b
commit
89448a7f5c
@ -578,7 +578,7 @@ def each_element(object)
|
||||
end
|
||||
|
||||
def fields_for_style?(object)
|
||||
(object.is_a?(Hash) || object.is_a?(Parameters)) &&
|
||||
object.is_a?(Parameters) &&
|
||||
object.to_unsafe_h.all? { |k, v| k =~ /\A-?\d+\z/ && v.is_a?(Hash) }
|
||||
end
|
||||
|
||||
@ -665,7 +665,7 @@ def hash_filter(params, filter)
|
||||
else
|
||||
# Declaration { user: :name } or { user: [:name, :age, { address: ... }] }.
|
||||
params[key] = each_element(value) do |element|
|
||||
if element.is_a?(Hash) || element.is_a?(Parameters)
|
||||
if element.is_a?(Parameters)
|
||||
element = self.class.new(element) unless element.respond_to?(:permit)
|
||||
element.permit(*Array.wrap(filter[key]))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user