This project is archived and is in readonly mode.
Automatic validation on has_many should not be performed twice
Reported by wildchild | June 25th, 2008 @ 10:51 AM
I found that has_many performs automatic validation of associated records and if "validates_associated" declared then validation performed twice.
This is very painful if different error message needed (eg. other language), also this behavior will produce many similar error messages if more then 1 associated records are invalid (don't think that it's useful).
I see different ways to workaround:
1) Check that associated object already validated (new property needed)
2) Check that validates_associated performed (don't know how to check this)
3) Check for record.errors.any? before calling record.valid? but for valid records validation will be performed again (possible overhead for complicated validations)
Any ideas, guys?
Comments and changes to this ticket
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Tickets have moved to Github
The new ticket tracker is available at https://github.com/rails/rails/issues