lundi 16 octobre 2017

Assertion Failed: You can no longer pass a modelClass as the first argument to store._buildInternalModel. Pass modelName instead

I have two models: A PoI and a Review. A PoI may contain multiple Reviews. However, I get an error

Assertion Failed: You can no longer pass a modelClass as the first argument to store._buildInternalModel. Pass modelName instead.

My models look like this:
poi.js:

import DS from 'ember-data';

export default DS.Model.extend({
    title: DS.attr('string'),
    description: DS.attr('string'),
    category: DS.attr('string'),
    longitude: DS.attr('number'),
    latitude: DS.attr('number'),
    radius: DS.attr('number'),
    rating: DS.attr(),
    images: DS.attr(),
    videos: DS.attr(),
    audio: DS.attr('string'),
    reviews: DS.hasMany('poi-review'),
});
import DS from 'ember-data';

export default DS.Model.extend({
  username: DS.attr('string'),
  date: DS.attr('date'),
  headline: DS.attr('string'),
  text: DS.attr('string'),
  rating: DS.attr('number'),
  poi: DS.belongsTo('poi')
});

my poi serializer looks like this:

import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  attrs: {
    reviews: {
      embedded: 'always',
    }
  },
  normalizeResponse(store, primaryModelClass, payload, id, requestType) {
    if (payload.array) {
      payload = {
        pois: payload.array
      };
    } else {
      payload = {
        poi: payload
      }
    }
    return this._super(store, primaryModelClass, payload, id, requestType);
  },
});

what exactly am I doing wrong? I couldn't find any solution in the internet and the documentation doesn't really help either.




Aucun commentaire:

Enregistrer un commentaire