How can I differentiate between 2 routes when resetNamespace is set to true?

I’m building an app in Ember 2.2 and I have a modal – activations – that I want to be able to open on top of 2 different routes – index and show. I’ve setup the router as follows:

Router.map ->
  @route 'rules', path: '/', ->
@route 'index', path: '/', ->
  @route 'activations', resetNamespace: true
@route 'new'
@route 'show', ->
  @route 'activations', resetNamespace: true
@route 'edit'
@route 'schedule'

This works just the way I want it to when I enter the urls in the address bar (i.e. the activations template is rendered into the index’s outlet from /activations and it’s rendered into the show’s outlet in /show/activations).

But, when I try to use the link-to helper in a template, it always redirects to /show/activations:

app/templates/rules/index.emblem

li: link-to 'activations' | activations

I’d expect the above to transition to /activations and render the activations template in the index’s outlet. Instead, it’s transitioning to show and rendering the template in there.

Any ideas?

Hints, tips or tricks would be greatly appreciated.

Thanks!

I stumbled on this recently, and could not find a neat solution. It appears the Router will just pick one route as the one and only parent for your nested route.

I ended up duplicating the route. Well, not exactly duplicating, but making it into a mixin, which I simply…

import Ember from 'ember';
import ArticleRouteMixin from 'mixins/article-route';
export default Ember.Route.extend(ArticleRouteMixin);

Ember is happy because it has two different routes, I am happy because I only have the code in one file. If you find a better way, please let me know.

Thanks for the tip.

I think I’ll open a bug for this because the docs explicitly say that resetNamespace is for reusing routes in multiple route trees.

Edit:

there’s already an open issue on github: https://github.com/emberjs/ember.js/issues/11692