instance method
array_filter?
Ruby on Rails 8.1.2
Since v8.0.4 PrivateAvailable in: v8.0.4 v8.1.2
Signature
array_filter?(filter)
When an array is expected, you must specify an array explicitly using the following format:
params.expect(comments: [[:flavor]])
Which will match only the following array formats:
{ pies: [{ flavor: "rhubarb" }, { flavor: "apple" }] }
{ pies: { "0" => { flavor: "key lime" }, "1" => { flavor: "mince" } } }
When using permit, arrays are specified the same way as hashes:
params.expect(pies: [:flavor])
In this case, permit would also allow matching with a hash (or vice versa):
{ pies: { flavor: "cherry" } }
Parameters
-
filterreq
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 1256
def array_filter?(filter)
filter.is_a?(Array) && filter.size == 1 && filter.first.is_a?(Array)
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 1256
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters