# Associations: Should "parent" and "parent.children.first.par

**URL:** <https://www.ruby-forum.com/t/associations-should-parent-and-parent-children-first-par/84587>\
**Category:** Rails\
**Created:** [February 6, 2007, 5:33am UTC](https://www.ruby-forum.com/t/associations-should-parent-and-parent-children-first-par/84587 "2007-02-06T05:33:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![inkling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f17d59/32.png) [@inkling](https://www.ruby-forum.com/u/inkling)\
**Post date:** [February 6, 2007, 5:33am UTC](https://www.ruby-forum.com/t/associations-should-parent-and-parent-children-first-par/84587/1 "2007-02-06T05:33:55Z")

</div>

Because it’s not, they have totally different object\_ids. But should  
they be pointing to the same object?

---

<div class="post-metadata">

**Author:** ![inkling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f17d59/32.png) [@inkling](https://www.ruby-forum.com/u/inkling)\
**Post date:** [February 6, 2007, 5:41am UTC](https://www.ruby-forum.com/t/associations-should-parent-and-parent-children-first-par/84587/2 "2007-02-06T05:41:55Z")

</div>

On 2/5/07, inkling [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Because it’s not, they have totally different object\_ids. But should  
> they be pointing to the same object?

Should be, assuming the current record is the first child of the  
parent. However, there’s no identity cache for AR, so they will be  
different ruby objects.

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![inkling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f17d59/32.png) [@inkling](https://www.ruby-forum.com/u/inkling)\
**Post date:** [February 6, 2007, 5:49am UTC](https://www.ruby-forum.com/t/associations-should-parent-and-parent-children-first-par/84587/3 "2007-02-06T05:49:56Z")

</div>

Ahh, I wasn’t clear, but you answered my question. Thanks!

Yes they point to the same record in the database, but yes I just  
wanted to make sure it was expected they are different ruby objects.

Are there any plans for doing some identity caching in the future or  
has there been some discussion that it is ideal for “parent” and  
“parent.children.first.parent” to be different ruby objects?

---

<div class="post-metadata">

**Author:** ![inkling](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/f17d59/32.png) [@inkling](https://www.ruby-forum.com/u/inkling)\
**Post date:** [February 6, 2007, 6:41am UTC](https://www.ruby-forum.com/t/associations-should-parent-and-parent-children-first-par/84587/4 "2007-02-06T06:41:58Z")

</div>

On 2/5/07, inkling [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ahh, I wasn’t clear, but you answered my question. Thanks!
> 
> Yes they point to the same record in the database, but yes I just  
> wanted to make sure it was expected they are different ruby objects.
> 
> Are there any plans for doing some identity caching in the future or  
> has there been some discussion that it is ideal for “parent” and  
> “parent.children.first.parent” to be different ruby objects?

No plans. There’s been some discussions on it though. Simple  
identity caches are easy, but it gets pretty complex pretty quickly.  
It’s usually not a big deal with most web apps I guess.

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
