Hi all
In my app I need that when I visit the root, it redirects to the view of the most recent model that in this case is always the firstObject 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() {
// console.log('in model);
return this.store.find('thread');
},
afterModel: function(threads) {
// console.log('in afterModel);
this.transitionTo('threads.view', threads.get('firstObject'));
}
});
This is working without problems, but wheter I directly go to the root url or to the view url, 2 identical requests to /threads
are made. With the help of console.log()
we can see that model and afterModel are both triggered 2 times. As soon I comment the afterModel section the redirection obviously doesn’t work anymore but the requests are back to 1.
Moreover according to this Changelog and the doc about transitionTo the child model hook should never be triggered, shouldn’t it?
Any help is gladly accepted!