In the docs, they have:
params = ActionController::Parameters.new(person: { name: "Francesco" })
and then use params.fetch(:person) to get person, but can't you just do params[:person]? to get the same data?
I suppose it depends on the behavior you desire.
params = ActionController::Parameters.new
params.fetch(:person)
Will raise an error. As reflected in the docs, you can specify further behavior with fetch, if you so desire.
params = ActionController::Parameters.new
params[:person]
Will return nil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With