Reputation: 44331
In order to share code between my different routes (they are mostly the same), I am trying to do the following:
/// Base classes (not real routes)
App.RouteMixin = Ember.Mixin.create({
...
});
App.BaseIndexRoute = Ember.Route.extend(App.RouteMixin, {
...
});
/// NODES
App.rNodesMixin = Ember.Mixin.create({
...
});
App.NodesIndexRoute = App.BaseIndexRoute.extend(App.rNodesMixin, {
...
});
App.NodesShowRoute = App.BaseShowRoute.extend(App.rNodesMixin, {
...
});
App.NodesEditRoute = App.BaseEditRoute.extend(App.rNodesMixin, {
...
});
App.NodesNewRoute = App.BaseNewRoute.extend(App.rNodesMixin, {
...
});
/// AGENTS
App.rNodesMixin = Ember.Mixin.create({
...
});
App.AgentsIndexRoute = App.BaseIndexRoute.extend(App.rAgentsMixin, {
...
});
App.AgentsShowRoute = App.BaseShowRoute.extend(App.rAgentsMixin, {
...
});
App.AgentsEditRoute = App.BaseEditRoute.extend(App.rAgentsMixin, {
...
});
App.AgentsNewRoute = App.BaseNewRoute.extend(App.rAgentsMixin, {
...
});
And suddently I am getting the following errors:
Assertion failed: The attempt to linkTo route 'nodes.index' failed. The router did not find 'nodes.index' in its possible routes: 'index'
The same pattern has worked for the controllers. Is it not possible to reuse code for the routes, with mixin/extend?
Upvotes: 1
Views: 300
Reputation: 19128
I think that you have some error in your router mapping.I had just changed the router mapping and works. Give a look in this Jsfiddle
I have used the following configuration:
App.Router.map(function() {
this.resource("nodes", function(){
// other routes
});
this.resource("agents", function(){
// other routes
});
});
Upvotes: 1