I like how single table inheritance works, in that you can share functionality
and validation etc between related models. The only thing I don't like is that
everything gets mixed into the same table. Quite often I end up with a lot of
redundant fields in a lot of records.
Is there any way to cause inheritance without triggering the STI special
Gareth, I too wasn't too happy with some aspects of STI, but to be fair
the constraints are pointed out in the Agile Rails book.
I am going to try the following for the scenarion where a number of z
subclasses inherit from a single y class which in turn inherits from a
single x class, and where z subclasses may be very different from
The solution I plan to try is:
1) One controller with a new() action that instantiates the base class
(x) and correct subclasses (y,z) for the input form data (using a
'type' selected in the UI)
2) Create action that saves x and thru table association (e.g. has one,
belongs to) saves the appropriate subclasses (y,z).
3) Individual models - one for x and y, and one for each sub class z.