Method: ActionController::Parameters#slice

Defined in:
lib/action_controller/metal/strong_parameters.rb

#slice(*keys) ⇒ Object

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) # => #<ActionController::Parameters {"a"=>1, "b"=>2} permitted: false>
params.slice(:d)     # => #<ActionController::Parameters {} permitted: false>


852
853
854
# File 'lib/action_controller/metal/strong_parameters.rb', line 852

def slice(*keys)
  new_instance_with_inherited_permitted_status(@parameters.slice(*keys))
end