instance method
[]
Ruby on Rails 8.0.4
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 229
def [](attribute)
messages_for(attribute)
end
Defined in activemodel/lib/active_model/errors.rb line 229
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors