Using redirection
In router.js
App.Router.map(function() { this.route('accomodations'); this.route('travel'); });
In routes/travel.js
App.TravelRoute = Ember.Route.extend({ redirect: function() { this.transitionTo('accomodations'); }, });
You do not need to put them in separate files (exactly where I would put them).
What this means is register two routes with a router. Select one as the โprimaryโ route and the other as the โnicknameโ. In this case, accomodation is the main route, and travel is its alias. When a user visits /travel , they are redirected to /accomodation .
This will be the Ember standard / standard way to achieve this, and if that is good for you, go for it.
Another possible solution
If you donโt want the redirect to happen for some reason, and you want the URL that the user sees to stay the same, but still display the same things and behave the same, this is also possible.
In this case, you will create two of each Ember element (route, controller, view, template). A sensible way would be to create a base class route, and both App.TravelRoute and App.AccomodationRoute trivially extend it; create a base class controller, and both App.TravelController and App.AccomodationController trivially extend it; the same for submissions, if you have them.
Templates, OTOH, are a bit more complicated because there is no way to extend them (which I know). So what you need to do is create a partial or component (which works best for you) and then reuse the partial / component in both templates/accomodation.hbs and templates/travel.hbs
source share