in my application, I need to be redirected to the latest model when visiting the root, which in this case is always the first object in the collection.
App.Router.map(function() {
this.resource('threads', { path: '/' }, function() {
this.route('view', { path: ':thread_id' });
});
});
App.ThreadsRoute = Ember.Route.extend({
model: function() {
return this.store.find('thread');
},
afterModel: function(threads) {
this.transitionTo('threads.view', threads.get('firstObject'));
}
});
This works without problems, but if I go straight to the root URL or view, 2 identical requests will be made to /threads. As soon as I comment on the section afterModel, the redirect obviously doesn't work anymore, but the queries return to 1.
Any help is gladly accepted!
Fed03 source
share