Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
adambedford opened this issue Mar 25, 2019 · 1 comment

Comments

@adambedford
Copy link

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.

@Skwai
Copy link

Skwai commented Mar 28, 2023

Just encountered this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants