instance method
delete
Ruby on Rails 7.1.6
Since v3.1.12Signature
delete(attribute, type = nil, **options)
Delete messages for key. Returns the deleted messages.
person.errors[:name] # => ["cannot be nil"] person.errors.delete(:name) # => ["cannot be nil"] person.errors[:name] # => []
Parameters
-
attributereq -
typeopt = nil -
optionskeyrest
Source
# File activemodel/lib/active_model/errors.rb, line 215
def delete(attribute, type = nil, **options)
attribute, type, options = normalize_arguments(attribute, type, **options)
matches = where(attribute, type, **options)
matches.each do |error|
@errors.delete(error)
end
matches.map(&:message).presence
end
Defined in activemodel/lib/active_model/errors.rb line 215
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors