How to use afterModel results in setupController

@davewasmer Yea, I think more controllers is not a bad thing. It was something I had resisted for a while (See this ugly implementation and Alex Speller’s elegant, and now obvious, alternative). Once I embraced the idea of “controllers for everything!”, my code really started to become much much more simple to read and reusable. (And it finally made the {{render}} helper useful for me. Perhaps in your situation, you might be able to just do {{render 'trendingPosts'}} and have a separate named template and everything for that other controller)

But, I do think that you have a valid need here for which there is not an obvious solution. I think that the intent behind the afterModel hook is not for loading data per se, but allowing you to validate asynchronously wether this route should in fact be loaded. (This replaced the redirect hook back before the router was completely asynchronous).

Maybe your idea should be worked into a new hook…a metaModel hook or something that pauses the transition as you would expect, but also allows you to load other models for a particular route? (Ignoring the fact that it’d be a breaking change to do it the way I outline…but perhaps here’s what it could look like). I think this could help many of us who have run into this problem in the past and had different ways of solving it…

App.PostRoute = Ember.Route.extend({
  model: function(params) {
    return this.store.find('post', params.post_id);
  },
  metaModel: function() {
    return this.store.find('post', {trending: true});
  },
  // This is the breaking change as the transition object would become the 4th arg
  setupController: function(controller, model, metaModel/*, transition*/) {
    controller.set('model', model);
    controller.set('trendingPosts', metaModel);
  }
});

Thoughts?