How to model Hibernate multi-table inheritance with ActiveRe

Hi

I have this “old” database mainly modeled for Hibernate. The java model
has something called Asset. Asset is inherited by SomeAsset and
AnotherAsset and the similar stuff is in the asset table and the
specific data for SomeAsset is in table some_asset and for AnotherAsset
in another_asset. This is then reflected in hibernate using a
element.

What would be the best way to model this in ActiveRecord? I cannot
change the exisiting database structure beyond adding new columns (ie I
cannot move values from the join tables back to the main table and use
STI).

Could I implement method_missing in Asset to just delegate to methods
that might exist in SomeAsset or AnotherAsset? I only use duck typing so
from a type perspective it would be fine. Would I crash Rails in some
way? Is there another better solution?

Best Regards,

Marcus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs