Documentation: https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-dig
I run rails c
and write this:
params = ActionController::Parameters.new(foo: { bar: { baz: 1 } })
And further:
params.dig(:foo, :bar, :baz)
These two lines I took from the page, the link to which is given above.
As a result, I get nil
.
When working with Hash
everything is fine. There is a problem when working with ActionController::Parameters
. I have this problem inside the Rails application.
Need your opinion on this.
params.dig(*%w[foo bar baz]) => nil
nope :( I tried both strings, and symbols, and combining them... – Colibri Dec 28 '18 at 11:581
. What rails version are you using? – P. Boro Dec 28 '18 at 11:58ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-darwin17]
andRails 5.2.2
. – Colibri Dec 28 '18 at 11:59params.to_unsafe_h.dig(:foo, :bar, :baz)
?, wondering the unsafe part. – Sebastian Palma Dec 28 '18 at 11:59