Rails 5 - Object Relation Impedence and how to structure multiple inherited classes/tables

后端 未结 3 1761
Happy的楠姐
Happy的楠姐 2021-01-18 12:42

EDIT I have edited this from the original to make it easier to understand.


I understand the Object Relationship Impedance problem. I understan

3条回答
  •  一整个雨季
    2021-01-18 13:14

    1. On the migration, drop the FK constraints on the addressses table. On the child classes redefine the has_many relation and specify :foreign_key & :foreign_type.

    2. On your Assignment serializer, specify the belongs_to :employee, AMS should handle it correctly.

      Also take a look at the :source and :source_type options of the has_many association.

提交回复
热议问题