instance method
[]=
Ruby on Rails 5.0.7.2
Last seen in v5.0.7.2Signature
[]=(attribute, error)
Adds to the supplied attribute the supplied error message.
person.errors[:name] = "must be set"
person.errors[:name] # => ['must be set']
Parameters
-
attributereq -
errorreq
Source
# File activemodel/lib/active_model/errors.rb, line 180
def []=(attribute, error)
ActiveSupport::Deprecation.warn(<<-MESSAGE.squish)
ActiveModel::Errors#[]= is deprecated and will be removed in Rails 5.1.
Use model.errors.add(:#{attribute}, #{error.inspect}) instead.
MESSAGE
messages[attribute.to_sym] << error
end
Defined in activemodel/lib/active_model/errors.rb line 180
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors