proper use of validates_associated

Hi All,

Is anyone using validates_associated in a productive manner?
What I mean is that I have not figured out how validates_associated is
actually supposed to make life easier.

I have been playing with this a little but have not gotten much out if
it. For example I have a Person model and an Activation model. In the
Person model I have defined validates_associated :activations (Person
has a 1..n with Activation)

When I do this for example after attempting person.save

<%= error_messages_for 'person' %>

and there is something invalid in an Activation instance associated
with the person I simply get an error message (actually I get it twice,
not sure why yet) stating that "Activations is invalid" rather than the
specific error for the attribute which failed validation in the
Activation instance. This is not very useful.

Alternatively I can of course validate the person instance and
activation instance independantly and then dig out the
error_messages_for for each instance but this is a little redundant.

Anyone have any good example or some good reading which discusses
validates_associated in more detail?

Thanks,
Serge

I'm doing something very similar and am using this:

http://railtie.net/articles/2006/01/26/enhancing_rails_errors

to report errors in a single error_messages_for report. However, it is
still showing "ModelName is invalid" as well as the other error
messages, which while not ideal will have to do at the moment!

See ActiveRecord::Associations#add_multiple_associated_save_callbacks
This method adds validations for all associated objects. If you add your
own validation with validates_associated you get double validation --
and double error messages -- for the same thing.

I only found out today myself.

Michael