# How do I extend a built-in nested route in Ember?

**URL:** https://meta.discourse.org/t/how-do-i-extend-a-built-in-nested-route-in-ember/53467
**Category:** Development
**Created:** [November 28, 2016, 6:21am UTC](https://meta.discourse.org/t/how-do-i-extend-a-built-in-nested-route-in-ember/53467 "2016-11-28T06:21:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 28, 2016, 6:21am UTC](https://meta.discourse.org/t/how-do-i-extend-a-built-in-nested-route-in-ember/53467/1 "2016-11-28T06:21:36Z")

</div>

Mainly a question for @eviltrout

I am trying to extend some of the internal routes for the solved plugin.

I tried adding `assets/javascripts/discourse/solved-route-map.js` with:

```plaintext
export default function() {
  this.route('user', { resetNamespace: true, path: '/users/:username'} , function() {
    this.route('userActivity', { resetNamespace: true, path: 'user-activity' } , function() {
      this.route('solved');
    });
  });
};

```

Trouble is that it blows away the existing routes and pretty much breaks everything, I also tries with `resource` using the other mechanism but it does not play nice with nested routes.

Any idea how I would go about doing this?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [November 28, 2016, 6:46pm UTC](https://meta.discourse.org/t/how-do-i-extend-a-built-in-nested-route-in-ember/53467/2 "2016-11-28T18:46:58Z")

</div>

This is not super well documented, but the route maps are actually designed just for this purpose!

You should be able to do this:

```javascript
export default {
  resource: 'userActivity',
  map() { 
     this.route('solved');
  }
};

```

The `resource` key in the object tells my custom route map code to attach the routes inside that resource.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 29, 2016, 4:50am UTC](https://meta.discourse.org/t/how-do-i-extend-a-built-in-nested-route-in-ember/53467/3 "2016-11-29T04:50:35Z")

</div>

Yeah, I tried that but it fails to map right cause it is nested ☹ :

 ![](https://global.discourse-cdn.com/meta/original/3X/1/3/13d157154c595bd9199b818abf5e626faf5b3ebe.png)

 ![](https://global.discourse-cdn.com/meta/original/3X/2/7/27b188397ff8e49d401e6b069c6213dad517ce33.png)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [November 29, 2016, 6:10pm UTC](https://meta.discourse.org/t/how-do-i-extend-a-built-in-nested-route-in-ember/53467/4 "2016-11-29T18:10:29Z")

</div>

Okay, I got this working although it meant a 100% rewrite of how my route map worked!

[https://github.com/discourse/discourse/commit/4e251eaf080cb3d77eca843a47a8a950060d2564](https://github.com/discourse/discourse/commit/4e251eaf080cb3d77eca843a47a8a950060d2564)

Using what I suggested above (with a small change) will now work:

```javascript
export default {
  resource: 'user.userActivity',
  map() { 
    this.route('solved');
  }
};

```
