What are the possible solutions to OO/Table inheritance (ie. STI,MTI,CLI) in Rails 5+?

放肆的年华 提交于 2019-12-24 02:44:12

问题


These are the options I see that can help solve "Rails 5 - Object Relation Impedence and how to structure multiple inherited classes/tables" TL;DR - the Object Table Impedance ORM problem.

  1. Abstract base class, with each child class having its own table (ie storing the common attributes for each type in its own table)

  2. STI, just put everything in one Base class and Table, and create all child attributes in that table, but have the sub-classes (ie your other Rails models) inherit from that Base Class.

  3. Sequel db (supports Class Table Inheritance)

  4. Dan Chak's 'Enterprise Rails' solution (here), seems quite old but looks promising

  5. Composition

Are there any others?

来源:https://stackoverflow.com/questions/39524564/what-are-the-possible-solutions-to-oo-table-inheritance-ie-sti-mti-cli-in-rai

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!