instance method
[]
Ruby on Rails 6.1.7.10
Since v2.2.3Signature
[](attribute)
When passed a symbol or a name of a method, returns an array of errors for the method.
person.errors[:name] # => ["cannot be nil"] person.errors['name'] # => ["cannot be nil"]
Parameters
-
attributereq
Source
# File activemodel/lib/active_model/errors.rb, line 207
def [](attribute)
DeprecationHandlingMessageArray.new(messages_for(attribute), self, attribute)
end
Defined in activemodel/lib/active_model/errors.rb line 207
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors