I am trying to get my head around Ember.js and I have a CRUD ember application that currently has two models- user and subject. A user can be associated with many subjects. My router.js looks like this:
App.Router.map(function(){
this.resource('users', function(){
this.resource('user', { path:'/:user_id' }, function(){
this.route('edit');
});
this.route('create');
});
this.resource('subjects', function(){
this.resource('subject', {path: '/:subject_id'}, function(){
this.route('edit');
});
this.route('create');
});
});
Each subject has a number of categories, which will also have CRUD functionality, so I now need to implement a categories model. My question is, what would be the most effective way of modelling the routing for the categories? Should I define it as a separate route structure or as a resource within the subjects routing? I have attempted the latter but it messed up my entire app and nothing rendered in the browser. Any suggestions/ links to examples very much appreciated.
EDIT: Categories routing
App.CategoriesRoute = Ember.Route.extend({
model: function(){
return this.store.find('category');
}
});
App.CategoryRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('category', params.category_id);
}
});