When saving the record, ensure that the superclass is saved also. This is necessary if the child class is not timestamped.
Set the inverse of the relations for the subclass.
Simplify the code using class_eval and a block without the need for a code text block.