instance method
[]
Ruby on Rails 3.1.12
Since v2.2.3Signature
[](attribute)
When passed a symbol or a name of a method, returns an array of errors for the method.
p.errors[:name] # => ["can not be nil"] p.errors['name'] # => ["can not be nil"]
Parameters
-
attributereq
Source
# File activemodel/lib/active_model/errors.rb, line 124
def [](attribute)
get(attribute.to_sym) || set(attribute.to_sym, [])
end
Defined in activemodel/lib/active_model/errors.rb line 124
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors