method
slice
v7.1.3.2 -
Show latest stable
- Class:
ActionController::Parameters
slice(*keys)public
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>