This project is archived and is in readonly mode.

#1686 ✓committed
Josh Susser

cleanup and speedup of validates_associated

Reported by Josh Susser | January 2nd, 2009 @ 05:41 AM | in 2.x

This is a tiny patch to improve the readability and performance of #validates_associated in ActiveRecord. The obscure use of #inject is replaces by #collect and #all?, using #collect to preserve the semantics of testing every record for validity by preventing early termination of the #all? loop. This is not only more readable, but about 40% faster too.

I wanted to replace the ternary operator that tests whether the value is an Array with the Array() coercion method, but that didn't work well with the association proxy, so that bit of ugliness remains.

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 »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages