Rails Polymorphic conundrum

I’m making a database that requires many-to-many associations. Here’s
the design:

There is a class called ‘Owner’ that owns many ‘Boxes’, ‘Things’,
‘Doodads’, and ‘Thingamabobs’

‘Boxes’ can have many ‘Things’, ‘Doodads’, and ‘Thingamabobs’, and
each ‘Thing’, ‘Doodad’, or ‘Thingamabob’ can belong to many :boxes. Do
I just need to make three separate join tables, or is there any way to
create this with a polymorphic association like so:

BoxesContents
box_id
content_type
content_id

(content being a :thing, :doodad, or :thingamabob

I’m pretty confident you can’t do polymorphic with HABTM. You can with a
one-to-many (has_many, belongs_to) but not with HABTM.

steve

Is it possible to do this without the use of has_and_belongs_to_many?

On Sep 16, 3:07 am, Steve R. [email protected]

theLemcke wrote:

Is it possible to do this without the use of has_and_belongs_to_many?

Without looking at your case in detail, let me remind you that any habtm
can also be represented by an equivalent has_many :through.

On Sep 16, 3:07�am, Steve R. [email protected]

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]