instance method
except
Ruby on Rails 4.2.9
Since v2.3.18 Last seen in v7.2.3Signature
except(*keys)
Returns a hash that includes everything but the given keys.
hash = { a: true, b: false, c: nil} hash.except(:c) # => { a: true, b: false} 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 9
def except(*keys)
dup.except!(*keys)
end
Defined in activesupport/lib/active_support/core_ext/hash/except.rb line 9
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Hash