instance method
dig
Ruby on Rails 5.0.7.2
Since v5.0.7.2Signature
dig(*keys)
Extracts the nested parameter from the given keys by calling dig at each step. Returns nil if any intermediate step is nil.
params = ActionController::Parameters.new(foo: { bar: { baz: 1 } }) params.dig(:foo, :bar, :baz) # => 1 params.dig(:foo, :zot, :xyz) # => nil
params2 = ActionController::Parameters.new(foo: [10, 11, 12]) params2.dig(:foo, 1) # => 11
Parameters
-
keysrest
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 604
def dig(*keys)
convert_value_to_parameters(@parameters.dig(*keys))
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 604
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters