Method: Hash#except
- Defined in:
- lib/active_support/core_ext/hash/except.rb
#except(*keys) ⇒ Object
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))
10 11 12 |
# File 'lib/active_support/core_ext/hash/except.rb', line 10 def except(*keys) dup.except!(*keys) end |