Method: ActiveModel::Errors#delete
- Defined in:
- activemodel/lib/active_model/errors.rb
#delete(attribute, type = nil, **options) ⇒ Object
Delete messages for key. Returns the deleted messages.
person.errors[:name] # => ["cannot be nil"]
person.errors.delete(:name) # => ["cannot be nil"]
person.errors[:name] # => []
215 216 217 218 219 220 221 222 |
# File 'activemodel/lib/active_model/errors.rb', line 215 def delete(attribute, type = nil, **) attribute, type, = normalize_arguments(attribute, type, **) matches = where(attribute, type, **) matches.each do |error| @errors.delete(error) end matches.map(&:message).presence end |