slice!(*keys)
public
Removes all errors except the given keys. Returns a hash containing
the removed errors.
person.errors.keys
person.errors.slice!(:age, :gender)
person.errors.keys
# File activemodel/lib/active_model/errors.rb, line 146
def slice!(*keys)
deprecation_removal_warning(:slice!)
keys = keys.map(&:to_sym)
results = messages.dup.slice!(*keys)
@errors.keep_if do |error|
keys.include?(error.attribute)
end
results
end