title: Multiple polymorphic relationships in Ember (Octane) models and Mirage
body: <p>In our Rails backend, we have a lot of <code>Concerns</code> server side. For example, several models import an <code>AppointableConcern</code> which allows the resources to be associated with <code>Appointments</code>. Each model can import an unlimited number of <code>Concerns</code>.</p>
  <p>In our Ember Octane models, we use inheritance instead, and I'm not sure whether that's a good idea. For example, we have these two models...</p>
  <pre><code>// models/groupable.js
  import { belongsTo } from '@ember-data/model';
  import ApplicationModel from './application'
  
  export default ApplicationModel.extend({
    group: belongsTo('group', { inverse: 'groupables' }),
  });
  
  // models/appointable.js
  import { hasMany } from '@ember-data/model';
  import Groupable from './groupable';
  
  export default Groupable.extend({
    appointments: hasMany('appointment')
  });
  
  </code></pre>
  <p>... as well as some models extending either <code>Appointable</code> or <code>Groupable</code>.</p>
  <p>To me it seems inheritance has been abused to share logic between classes that are not closely related: An <code>Appointable</code> is not a specific implementation of a <code>Groupable</code> (multiple <code>Groupables</code> can form a <code>Group</code>) at all.</p>
  <p>Now I wonder:</p>
  <ul>
  <li>Is this a recommended/standard way to share this logic between models?</li>
  <li>Is there a more flexible alternative? Considering my example above, directly using <code>group: belongsTo('group', { inverse: 'groupables' })</code> in any model that should be groupable and <code>appointments: hasMany('appointment')</code> in all models that appointments should be allowed to associate with seems like a simple solution.</li>
  </ul>
  <p><em>edit:</em></p>
  <p>We encountered a problem with the solution i sketched out above. It is related to EmberCLI Mirage tests: I wanted to make one more model <code>groupable</code>, but it does not fit in the inheritance chain well. We couldn't make it inherit from the <code>Groupable</code> model. So we added this line directly to the new model: <code>group: belongsTo('group', { inverse: 'groupables' })</code></p>
  <p>This works in the browser, but in Mirage I got this error:</p>
  <pre><code>The 'article' type does not implement 'groupable' and thus cannot be assigned to the 'groupables' relationship in 'group'. Make it a descendant of 'groupable' or use a mixin of the same name.
  </code></pre>
  <p>But as there is no multiple inheritance, I can't make <code>Article</code> a descendant of <code>Groupable</code> and there are no mixins in Mirage at all. So I removed <code>{ inverse: 'groupables' }</code> from my new model, which is ok for the moment, but we shouldn't need to take away functionality from our code just to make a test work.</p>