Hi all
I used rails 3.0.7 and found ActiveRecord::Errors#[] acts little bit
strange (at least for me).
Let's say we have a model like below.
class User < ActiveRecord::Base
validates :name, :presence => true
end
irb> u = User.new
irb> u.valid?
irb> u.errors #=> { :name => ["can not be nil"] }
irb> u.errors[:age] # => []
irb> u.errors #=> { :name => ["can not be nil"], :age => [] }
Thought ActiveRecord::Errors#[] looks like just an getter, it actually
rewrites itself.
Is this a correct behavior?
Regards
Shouichi
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.