Skip to content

Mixin pattern for polymorphic relationships doesn't seem to work with native classes #422

@adambedford

Description

@adambedford

Polymorphic relationships in Ember require either inheritance from a common parent or a mixin (with the name of the polymorphic relationship) to be applied. I'm trying to get the mixin solution working with an Ember Data model that uses native classes, however it doesn't seem that the mixin is being recognized. Inspecting the model shows that the mixin's properties were applied to the model, however.

The error I'm seeing is:

The 'lesson-reservation' type does not implement 'cancelable' and thus cannot be assigned to the 'cancelable' relationship in 'cancellation'. Make it a descendant of 'cancelable' or use a mixin of the same name.

The model is LessonReservation and the polymorphic association is cancelable. There is a mixin named cancelable.

The native class syntax doesn't work:

import DS from 'ember-data';
import Cancelable from 'frontend/mixins/cancelable';

const { Model } = DS;

export default class LessonReservationModel extends Model.extend(Cancelable) {
}

However, the traditional syntax does work:

import DS from 'ember-data';
import Cancelable from 'frontend/mixins/cancelable';

const { Model } = DS;

export default Model.extend(Cancelable, {

})

It may be that I'm misattributing this issue to ember-decorators when it's a more core Ember issue but this seemed like a good place to start. Any guidance would be very appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions