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

0

2

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?

Naamann answered 16/9, 2016 at 5:55 Comment(6)
Voting to close. It totally depends on what the actual domain problem you need to solve is. In most cases you don't need STI, MTI etc. You can usually get by with having a User model and a Role model (no pun intended).Mustache
Do I need to reword the question? You said "In most cases you don't need etc...." So what are the 'etc' - do you mean my list of 6, or are there more that you know of? This is exactly what the question is trying to get listed, what the different options are. I have listed 6 that I know of - none of which are domain dependent and all of which can be used to solve this problem in different domains/situations. Surely there must be others?Naamann
Edited to remove any domain-specific nomenclatureNaamann
Your question is still off-topic. Please read "How to Ask". You're asking us to give recommendations. Instead, SO wants you to do the research (gaining knowledge), to try things (gaining experience), then, when you can't implement something, ask a specific problem about that particular problem. “How much research effort is expected of Stack Overflow users?” 'splains this.Peregrination
Really like to ask "why everyone considering STI so harmful?" but prefer not to ask questions :)Keratoid
@theTinMan I am not asking for recommendations. I listed the 5 different solutions my own research has discovered to solving the problem and asking the community if that list is complete or not. I am not asking 'what do you recommend'? I am asking 'is this list of solutions complete'?Naamann

© 2022 - 2024 — McMap. All rights reserved.