instance method
except
Ruby on Rails 5.2.8.1
Since v2.3.18 Last seen in v7.2.3Signature
except(*keys)
Returns a hash that includes everything except given keys.
hash = { a: true, b: false, c: nil } hash.except(:c) # => { a: true, b: false } hash.except(:a, :b) # => { c: nil } hash # => { a: true, b: false, c: nil }
This is useful for limiting a set of parameters to everything but a few known toggles:
@person.update(params[:person].except(:admin))
Parameters
-
keysrest
Source
# File activesupport/lib/active_support/core_ext/hash/except.rb, line 12
def except(*keys)
dup.except!(*keys)
end
Defined in activesupport/lib/active_support/core_ext/hash/except.rb line 12
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Hash