Reputation: 102423
I'm learning Ember and trying to figure how to do a signup form.
I have a /users
route from before and I have created a users/new
route. In my users route I load all the users from the store - and now my users/new
route will load all the users - which is not really needed.
Should I create a separate users/index.js
route for the index or is there another way to override the parent model loading that I should be using?
// app/router.js
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('users', function() {
this.route('new');
});
this.route('users', function() {
this.route('new');
});
});
export default Router;
// routes/users.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function(){
return this.store.findAll('user');
}
});
// routes/users/new.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function(){
return this.store.createRecord('user');
}
});
Upvotes: 0
Views: 318
Reputation: 3669
If you do not need users
collection in the users
children routes, it is reasonable to create users.index
route and use users
collection as model in users.index
route only. In this case you could remove users
route and controller files.
Upvotes: 1