1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add documentation about method to describe how it works [ci skip]

This commit is contained in:
Mehmet Emin İNAÇ 2016-02-04 20:03:24 +02:00
parent e22404a8b2
commit e38ced376f

View file

@ -160,6 +160,15 @@ module ActiveModel
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors['name'] # => ["cannot be nil"]
#
# Note that, if you try to get errors of an attribute which has
# no errors associated with it, this method will instantiate
# an empty error list for it and +keys+ will return an array
# of error keys which includes this attribute.
#
# person.errors.keys # => []
# person.errors[:name] # => []
# person.errors.keys # => [:name]
def [](attribute)
messages[attribute.to_sym]
end