Child route logic being called before parent route logic. Is this right?

I have a route nested inside of a parent which inherits from a mixin.

// mixins/authenticated-base-route
    import Ember from 'ember';
    import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';

    export default Ember.Route.extend(AuthenticatedRouteMixin, {
      activate: function (){
         console.log('b')
         doSomeStuff();
      }
    });

/pods/admin/route.js
import AuthenticatedBaseRoute from 'web-ui/routes/authenticated-base-route';

export default AuthenticatedBaseRoute.extend({
  activate: function () {
    console.log('a')
    this._super();
    console.log('c')
  },
});

//pods/admin/flights/route.js
import Ember from 'ember';

export default Ember.Route.extend({
  afterModel: function () {
    console.log('d')
  },
});

My impressions was that route logic executes sequentially from the index route down.

My expectation would be then that my logs would git in the order of : a b c d

In reality though, when I hit the route “/admin/flights” directly through the url bar, the “afterModel” in “/admin/flights” executes before “activate” “admin” causing the log order to be:

“d a b c”

Is this a bug or is this expected behavior. If so can anyone point me to an explanation which would help me wrap my head around determining the execution order?

Any thoughts? I am still really baffled by this. It’s making me question some of my basic assumptions about how ember code executes.

As I understand it, all models are resolved then routes are activated (and the controllers are setup) so the order would be:

parent model > child model > activate/setupController parent > activate/setupController child.

JS Bin - Collaborative JavaScript Debugging is an old jsbin that might help :slight_smile:

I can’t believe I have been using Ember so long and never knew that. It seems like such a basic thing and definitely explains the behavior.

Thanks so much for the response.