fetch(key, *args)
Instance Public methods
Returns a parameter for the given key
. If the key
can't be found, there are several options: With no other arguments, it
will raise an ActionController::ParameterMissing
error; if
more arguments are given, then that will be returned; if a block is given,
then that will be run and its result returned.
params = ActionController::Parameters.new(person: { name: 'Francesco' }) params.fetch(:person) # => {"name"=>"Francesco"} params.fetch(:none) # => ActionController::ParameterMissing: param not found: none params.fetch(:none, 'Francesco') # => "Francesco" params.fetch(:none) { 'Francesco' } # => "Francesco"
Please login to continue.