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

Tidy up error.rb code

[#5288 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Subba Rao Pasupuleti 2010-08-03 12:35:58 -04:00 committed by Santiago Pastorino
parent 41c1aa607d
commit 8d9d8bc93c

View file

@ -86,11 +86,7 @@ module ActiveModel
# p.errors[:name] # => ["can not be nil"] # p.errors[:name] # => ["can not be nil"]
# p.errors['name'] # => ["can not be nil"] # p.errors['name'] # => ["can not be nil"]
def [](attribute) def [](attribute)
if errors = get(attribute.to_sym) get(attribute.to_sym) || set(attribute.to_sym, [])
errors
else
set(attribute.to_sym, [])
end
end end
# Adds to the supplied attribute the supplied error message. # Adds to the supplied attribute the supplied error message.