Forum: Ruby on Rails Re: Associations oddity

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.
4c3f6ae3543413647e6b3734c184f017?d=identicon&s=25 Paul Butcher (paulbutcher)
on 2006-02-04 23:17
(Received via mailing list)
Kent Sibilev wrote:
> This looks very strange, doesn't it?
>
> What happens is that when you call
>
> q.category
>
> you get AssociationProxy object which pretends to be another object.
> After you call

Thanks, Kent.

OK - I understand what's happening. I still think that it violates the
principle of least surprise! :-)

Regarding the second half of my question - is there a better way to
handle
the situation than "dup"?

I notice that AssociationProxy has a "target" method - which does seem
to do
the trick. Is this the best solution - or is there an alternative I
should
be aware of?

Thanks again!

(BTW - is it just me, or are others having problems with the forum
bridge at
the moment?)

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
This topic is locked and can not be replied to.