mardi 23 août 2016

EmberJS 2.7 assertion failed passing id of nested object

EmberJS 2.7 Error: Assertion Failed: id passed to findRecord() has to be non-empty string or number

app/templates/products/index.hbs: [inside the model/each loop I have this line]:

<a href=""></a>

app/router.js: [I have these routes defined]:

  this.route('products', function() {
    this.route('new');
    this.route('edit', { path: '/:product_id/edit' });
  });

  this.route('categories', function() {
    this.route('new');
    this.route('edit', { path: '/:category_id/edit' });
  });

It works when editing a product. But throws the above error when trying to edit a category.

If I delete the 'categories/edit' route and add this route instead:

this.route('category', { path: '/categories/:category_id/edit' });

and change the template to use that:

<a href=""></a>

Then it works. I understand why this second one works. But why does the first one not work?




Aucun commentaire:

Enregistrer un commentaire