Forum: Ruby on Rails Associations: Should "parent" and "parent.children.first.par

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4a2a0b54bfe512aefbd2e9185464d7a6?d=identicon&s=25 inkling (Guest)
on 2007-02-06 05:33
(Received via mailing list)
Because it's not, they have totally different object_ids.  But should
they be pointing to the same object?
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-02-06 05:41
(Received via mailing list)
On 2/5/07, inkling <nate@inventric.com> 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 Olson
http://weblog.techno-weenie.net
http://mephistoblog.com
4a2a0b54bfe512aefbd2e9185464d7a6?d=identicon&s=25 inkling (Guest)
on 2007-02-06 05:49
(Received via mailing list)
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?
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-02-06 06:41
(Received via mailing list)
On 2/5/07, inkling <nate@inventric.com> 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 Olson
http://weblog.techno-weenie.net
http://mephistoblog.com
This topic is locked and can not be replied to.