> It is a feature. The thing that you are missing is that you're not > using = on an array[1], you're calling the []= method on the errors > object which has overridden []= to append stuff. A more typical usage > with validations is that various errors are added to an attribute (or > to base) as time goes on. You can see what's being done > athttp://github.com/rails/rails/blob/master/activemodel/lib/active_mode... > which reveals that the original []= method is aliased as set
Thank you, Fred. As always, you are the MAN. I had a feeling it was something like this, but I just plain haven't noticed this behavior before, as I always use errors[:base] for one error at a time, and errors[:attribute] for each individual attribute for which there's an error. Just a practice I've used for a while, but this was obviously an "error 18" on my part, so thanks for pointing that out. > [1] Being nitpicky, = is one of the operators in ruby that is not > implemented via a method so writing "calling it" isn't quite write. > Also writing x= ["test"] does not replace the contents of an array - > it just points the local variable x at a new object. Thank you for the lesson here! I knew the second part (about passing it a memory pointer to a new object), but I wasn't even thinking about the nomenclature of "calling" versus ...using? Not sure what else to call it either. Anyway, I appreciate the information - thanks again! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" 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-talk?hl=en.

