[Rails] Re: Re: Polymorphic, many-to-many, self-referential data mod

Josh Susser
Sat, 20 May 2006 23:26:41 -0000

Jason King wrote:
> Wasn''t quite right, apart from the :source => :article and
:source => :book
> in the container, there were some other small things which brought
> things to
> a halt.  Basically in the "to elements" stuff in the Container
the lack of
> the foreign key in the "has_many :ownerships" (which
I''ve renamed) meant
> that the JOIN was wrong.

Ah yes, copy/paste is ever the bane of my postings. Cool that you got it
sorted out and that it''s working for you.

> I ended up coding things like this (with some slight name changes to make
> more sense, and some work on the "to elements" stuff in
Container).  I''m
> still not sure if this is the best way to do it, but it seems to work,
> and *does* actually make sense to me :)

If it works and makes sense to you, then it''s the right way :-)  I like
the way you changed the names of ownings/ownerships, I agree it reads
better. And I always like to look at the SQL in the log to make sure
things are getting put together right, but it sounds like you do that
too so I expect you''re OK.

> You truly are a legend, I knew this was complex, and throught that it
> might have been outside the realm of these helpers.  Thanks for taking the
> time to code up some very helpful code.

Glad to be of service. I love how helpful everyone is in this community,
just trying to do my part.

--
Josh Susser