method

except

v4.1.8 - Show latest stable - Class: Hash
except(*keys)
public

Returns a hash that includes everything but the given keys. This is useful for limiting a set of parameters to everything but a few known toggles:

@person.update(params[:person].except(:admin))

1Note

Passing an array of keys to exclude.

joshuapinter ยท May 1, 20142 thanks

Use the "*" before passing the array in. For example:

PARAMS_TO_SCRUB = [ :created_at, :updated, :id, :format ]

params.except!( *PARAMS_TO_SCRUB )