I am using ember 1.13, ember-cli and ember data 1.19.1 and I am experiencing an error that is difficult to track down due to being unspecific. The error occurs when I do the following:
this.get('model').forEach(function(mymodel) {
applications.push(mymodel.serialize({includeId: true}));
});
and a snippet of the error itself is:
Uncaught TypeError: Cannot read property 'modelFor' of
undefinedember$data$lib$system$model$$default.reopenClass.typeForRelationship @
ext.js:171ember$data$lib$system$model$$default.reopenClass._findInverseFor @
ext.js:214ember$data$lib$system$model$$default.reopenClass.inverseFor @
ext.js:205Ember.Mixin.create.removeEmbeddedForeignKey @ embedded-records-mixin.js:317
Ember.Mixin.create.serializeBelongsTo @ embedded-records-mixin.js:199
I have managed to discover that the model this error is occurring on ("mymodel") only throws the error when relationships to another model are included, e.g.
quickQuote: DS.belongsTo('iso-application-status')
I assume this message relates to a misconfiguration of one of my models/serializers but I've been through and can't find anything amiss. The "mymodel" model is called "my-model" and looks like this:
import DS from 'ember-data';
export default DS.Model.extend({
statusId: DS.attr('number'),
status: DS.belongsTo('iso-application-status')
});
and the serializer for this is also called "my-model" and looks like this:
import DS from "ember-data";
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
status: {embedded: 'always'}
}
};
The related model is "iso-application-status" and looks like this:
import DS from "ember-data";
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
myModels: {async: true},
}
});
Does anyone know what I have done wrong please?
Thanks.
Aucun commentaire:
Enregistrer un commentaire