jeudi 28 mai 2015

Error processing route when using modelFor in model hook

I have a route structure as follows:

this.route('brands', function() {
  this.route('brand', { path: ':brand_id' }, function() {
    this.route('items', function() {
      this.route('item', { path: ':item_id' });
    });
  });
});

Inside my items route I have the following model hook:

var brand = this.modelFor('brands.brand');
return brand.get('items');

When I start at the brand route and navigate towards an item route and then back to the items page, everything is fine. But, when I refresh at an item route and navigate back to the items route, Error while processing route: brands.brand.items.index is thrown.

I tracked it down to these two possible workarounds:

1) Use the following model hook on items:

let brand = this.modelFor('brands.brand')
return this.store.find('item', { brand: brand.id });

2) Comment out the brand relationship on the item model.

Ember isn't really helping here with a meaningful error message. All I can see is some arcane rejected promises like:

Router: 'application.brands.brands.brand.brands.brand.items.brands.brand.items.index': Resolve handler.

I'm using Ember 1.12.0 with Ember Data 1.0.0-beta.16.1.




Aucun commentaire:

Enregistrer un commentaire