[Nitro] Is there a reason I shouldn't want to do this?

Jonathan Buch john at oxyliquit.de
Fri Feb 9 04:19:17 EST 2007


> At present, this creates three tables, with a foreign key from
> og_target to og_owner, and the SubTarget gets lost because the select
> is against the og_target table.
> Is there a philosophy here that I'm not understanding?

well, yeah, like G already said:  You probably want STI in this case.

The philosophy here being the underlying database.  Because it creates
3 tables, it can't associate Owner with SubTarget with the same
foreign key.

class Target
   is Og::SchemaInheritanceBase
   attr_accessor :thing, String

With this your example will only create 2 tables and the foreign key
will be valid for both classes.

STI is always in a kind of flux though.  But generally it works well
when not doing anything too fancy.

Hope that helped,


Feel the love

More information about the Nitro-general mailing list