Getting error: you need to pass the model name to the storeFor model method

Using Ember 2.6.0

The following routes are defined:

Router.map(function() {
  this.route('brands');
  this.route('brand', {path: '/brands/:brand_id'});
});

Model for brand:

export default Model.extend({
  name: attr('string'),
  description: attr('string'),
  dateCreated: attr('date'),
  lastUpdated: attr('date'),
  regions: hasMany('region')
});

And a model for region:

export default Model.extend({
  name: attr('string'),
  dateCreated: attr('date'),
  lastUpdated: attr('date'),
  brand: belongsTo('brand')
});

Now, when you are trying to access /brands, I am doing this on the route:

export default Ember.Route.extend({
  model() {
    return this.store.findAll('brand');
  }
});

I get the following error:

You need to pass the model name to the modelFor method repository

This worked before adding routes brandand region. The brand is the parent, so I'm not sure why this is not working.

UPDATE:

Removing regions: hasMany('region')from the model brandallows you to work again. Not sure why it doesn't work with certain relationships.

+4
source share
1 answer

, . :

import RESTSerializer from 'ember-data/serializers/rest';
import DS from 'ember-data';

export default RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
  attrs: {
      regions: {embedded: 'always'}
  }
});

region :

import RESTSerializer from 'ember-data/serializers/rest';

export default RESTSerializer.extend({
});

, , , ember regions region. ember, RESTSerializer, .

+5

All Articles