This project is archived and is in readonly mode.
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
-
Repository January 22nd, 2009 @ 12:45 AM
- State changed from new to committed
- Tag set to activerecord, optimisation, tiny, validates_associated
(from [ccda96093a3bf3fb360f7c6d61bbbf341b2ae034]) Minor refactoring of validates_associated to replace #inject with #collect + #all?
[#1686 state:committed] http://github.com/rails/rails/co...
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
- 1686 cleanup and speedup of validates_associated [#1686 state:committed] http://github.com/rails/rails/co...