Reputation: 3110
I'm using Ember-Rails to build an Ember front-end app with a Rails API for a beckend. I've been working on implementing authentication, and I arrived at the following error:
Cannot read property 'extend' of undefined
when trying to extend a route as follows:
App.AdminRoute = App.AuthenticateRoute.extend({
model: function(params) {
return this.store.find('user', params.id);
},
});
And I had an AuthenticateRoute defined as follows:
App.AuthenticateRoute = Ember.Route.extend({
//yada yada
});
I was more-or-less following a guide found on: http://www.embercasts.com/episodes/client-side-authentication-part-2
I am not sure why this is not working, but I noticed my AuthenticateRoute could be extended from other routes, which I find extremely strange.
Upvotes: 1
Views: 1345
Reputation: 3110
Turns out that, as most of us know, Ember-Rails precompiles all these files without you seeing it (using what I believe is the Barber gem). What I didn't think about is that, when it combines all these files, it (as far as I can tell) puts them in alphabetical order. As such, my AdminRoute
was being declared as extending AuthenticateRoute
before AuthenticateRoute
was even declared, thus producing the error. I'm not yet sure how to solve this--
admin_route.js
to zadmin_route.js
, so it comes after authenticate_route.js
, though this isn't desirable for obvious reasons. If anyone has a superior alternative, please comment below, else I will update this when I come across a solution.
Upvotes: 2