# Altering an Ember Route in a Plugin

**URL:** https://meta.discourse.org/t/altering-an-ember-route-in-a-plugin/43332
**Category:** Development
**Created:** [Avril 27, 2016, 5:00 UTC](https://meta.discourse.org/t/altering-an-ember-route-in-a-plugin/43332 "2016-04-27T17:00:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [Avril 27, 2016, 5:00 UTC](https://meta.discourse.org/t/altering-an-ember-route-in-a-plugin/43332/1 "2016-04-27T17:00:16Z")

</div>

Continuing the discussion from [Discourse.Route.buildRoutes is not a function](https://meta.discourse.org/t/discourse-route-buildroutes-is-not-a-function/29825/8):

I am confused as to how to alter a route from within a plugin. Is it different then just following the same file path from within the plugin? In my plugin I have `plugin/assets/javascripts/discourse/routes/user-summary.js.es6` and I am adding `this.controllerFor("user").set("forceExpand", true);` …which will force the expanded profile view on summary.

```
export default Discourse.Route.extend({
  model() {
    this.controllerFor("user").set("forceExpand", true);
    return this.modelFor("User").summary();
  }
});

```

If I change the source code on my local Discourse it works but when I enable my plugin it does nothing. Now, I have had trouble recently where another plugin’s changes were not being picked up and the reason resolved itself mysteriously, so it could be that again.

But just to be safe, is altering routes in plugins different then what I am doing?

---

<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: [Avril 27, 2016, 5:27 UTC](https://meta.discourse.org/t/altering-an-ember-route-in-a-plugin/43332/2 "2016-04-27T17:27:59Z")

</div>

To modify a class you’ll need to use an initializer that looks up the ember class and reopens it. The code would look something like this:

```javascript
  const UserSummaryRoute = container.lookupFactory('route:user-summary');
  UserSummaryRoute.reopen({
    model() { /* new code */ }
  });

```
