mardi 24 février 2015

Trouble with nested resources

I'm new to Ember, and I think I bit off more than I can chew with this practice app, but I intend to learn. I might be completely conceptually off, if so, feel free to offer a better structure for my use case.


My (abbreviated) routing looks more or less like this:



Router.map(function() {
this.resource('shops', { path: '/' }, function() {
this.resource('shop', { path: ':shop_id' }, function() {
this.resource('items', { path: 'admin'}, function() {
});
});
});
});


The intention is that the user will select a shop, then get a list of all possible items with checkboxes where he can decide which are available in that shop and which aren't. So far, I'm just trying to display the list of all items, but it's not working. However, the list of shops - no problem whatsoever.




  • URL: /


    Works. model is all shops.




  • URL: /1


    Works. model is the shop with ID 1.




  • URL: /1/admin


    Error while processing route: locations.index Assertion Failed: ArrayProxy expects an Array or Ember.ArrayProxy, but you passed object




Both shops and items controllers are identical:



// app/controllers/shops.js
// app/controllers/items.js
export default Ember.ArrayController.extend({});


The routes are nearly identical:



// app/routes/shops/index.js
export default Ember.Route.extend({
model: function() {
return this.store.find('shop');
}
});

// app/routes/items/index.js
export default Ember.Route.extend({
model: function() {
return this.store.find('item');
}
});


The trek controller does not exist, and the trek.index route is trivial:



// app/routes/trek/index.js
export default Ember.Route.extend({});


What gives?





Aucun commentaire:

Enregistrer un commentaire