This project is archived and is in readonly mode.
AssociationCollection #first and #last cache.
Reported by Eloy Duran | January 13th, 2009 @ 07:39 PM | in 2.x
Sometimes when testing or in irb, I seem to forget that the following does not work:
first = firm.clients.first
firm.clients.each { ... } # loads the target and thus the instance is gone
firm.clients.first.object_id == first.object_id # => false
This patch solves this.
Note that the same queries as normal are executed, just the instance in the collection result is replaced.
Comments and changes to this ticket
-
Eloy Duran February 7th, 2009 @ 02:42 PM
- Assigned user set to Michael Koziarski
-
Michael Koziarski February 7th, 2009 @ 10:11 PM
- State changed from new to wontfix
I'd prefer not to apply a one off fix for this problem, instead a wider fix involving an identity map or something similar would be better.
-
Eloy Duran February 8th, 2009 @ 12:23 AM
Yeah I understand, an identity map would be much better. Another time ;-)
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
Tags
Referenced by
- 2149 Inconsistent has_many validation. I actually created a patch for this once, but it won't ge...
- 5053 child/grandchild associations reload from db after nested attributes assignment @Neeraj Well, I can think of two options. Either create/m...
- 5053 child/grandchild associations reload from db after nested attributes assignment I will take a look at #1751 and the other option you sugg...