class ActionController::Parameters
def fetch(key, *args)
params.fetch(:none, 'Francesco') # => "Francesco"
params.fetch(:none) # => ActionController::ParameterMissing: param is missing or the value is empty: none
params.fetch(:person) # => {"name"=>"Francesco"}
params = ActionController::Parameters.new(person: { name: 'Francesco' })
is given, then that will be run and its result returned.
if more arguments are given, then that will be returned; if a block
it will raise an ActionController::ParameterMissing error;
can't be found, there are several options: With no other arguments,
Returns a parameter for the given +key+. If the +key+
def fetch(key, *args) convert_value_to_parameters( @parameters.fetch(key) { if block_given? yield else args.fetch(0) { raise ActionController::ParameterMissing.new(key) } end } ) end