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 -- Posted via http://www.ruby-forum.com/.
Is it possible to do this without the use of has_and_belongs_to_many? On Sep 16, 3:07 am, Steve Rawlinson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 > -- > Posted viahttp://www.ruby-forum.com/.
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 Rawlinson <rails-mailing-l...@andreas-s.net>Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.