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))
Show source
Register or log in to add new notes.
May 1, 2014
2 thanks

Passing an array of keys to exclude.

Use the “*” before passing the array in. For example:

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

params.except!( *PARAMS_TO_SCRUB )