0
votes

I wanted to know if it is possible to have STI where the subclasses each relate to an unrelated model in different ways.

In other words, say B < A and C < A, and I implement single table inheritance on table A (e.g. a type column where you can have B or C to indicate a subclass).

Now let's say we have a separate model called Xyzzy.

Is it possible to implement a has_and_belongs_to_many relationship between C and Xyzzy while implementing a has_one relationship between B and Xyzzy?

How should I do this in the context of STI? Or would STI simply not affect this?

1

1 Answers

1
votes

There is nothing particular to do to make this happen. Simply create your relationships.

Indeed, even if B and C have access to some columns they don't care about, well... they simply don't care about.