inherited

inherited(klass) Instance Public methods Sets the default wrapper key or model which will be used to determine wrapper key and attribute names. Will be called automatically when the module is inherited.

_set_wrapper_options

_set_wrapper_options(options) Instance Public methods

permitted=

permitted=(new_permitted) Instance Protected methods

slice

slice(*keys) Instance Public methods Returns a new ActionController::Parameters instance that includes only the given keys. If the given keys don't exist, returns an empty hash. params = ActionController::Parameters.new(a: 1, b: 2, c: 3) params.slice(:a, :b) # => {"a"=>1, "b"=>2} params.slice(:d) # => {}

required

required(key) Instance Public methods Alias of require. require

require

require(key) Instance Public methods Ensures that a parameter is present. If it's present, returns the parameter at the given key, otherwise raises an ActionController::ParameterMissing error. ActionController::Parameters.new(person: { name: 'Francesco' }).require(:person) # => {"name"=>"Francesco"} ActionController::Parameters.new(person: nil).require(:person) # => ActionController::ParameterMissing: param not found: person ActionController::Parameters.new(person: {}).r

permitted?

permitted?() Instance Public methods Returns true if the parameter is permitted, false otherwise. params = ActionController::Parameters.new params.permitted? # => false params.permit! params.permitted? # => true

permit!

permit!() Instance Public methods Sets the permitted attribute to true. This can be used to pass mass assignment. Returns self. class Person < ActiveRecord::Base end params = ActionController::Parameters.new(name: 'Francesco') params.permitted? # => false Person.new(params) # => ActiveModel::ForbiddenAttributesError params.permit! params.permitted? # => true Person.new(params) # => #<Person id: nil, name: "Francesco">

permit

permit(*filters) Instance Public methods Returns a new ActionController::Parameters instance that includes only the given filters and sets the permitted attribute for the object to true. This is useful for limiting which attributes should be allowed for mass updating. params = ActionController::Parameters.new(user: { name: 'Francesco', age: 22, role: 'admin' }) permitted = params.require(:user).permit(:name, :age) permitted.permitted? # => true permitted.has_key?(:name) # =

fetch

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"}