"Before All" filter broken if defined in the controller?

158 views Asked by At

In my controller I define

PagesController.before('*', function(next) {
  console.log('zip');
  next();
});

And in routes.js I have

this.resources('pages', { only: [ 'index'] })

The "before" filter wasn't being executed. It looks like the code in the controller is being executed before the resources call, and so at the time the before filter is set up the array of actions is empty. Is this expected, and if so where should the before filter be specified (and would it be worth a warning in the docs). Or is this unexpected, in which case any suggestions for why this is happening?

1

There are 1 answers

3
wridgers On

Make sure your filter is at the bottom of your controller. :)