instance method
slice
Ruby on Rails 7.2.3
Since v4.0.13Signature
slice(*keys)
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>
Parameters
-
keysrest
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 725
def slice(*keys)
new_instance_with_inherited_permitted_status(@parameters.slice(*keys))
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 725
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters