In my ember app (1.0.0 production version) I have a URL structure as follows:
/item
/item/{specific-item-name-defined-in-routes}
The Router mapping looks a little like this:
App.Router.map(function () {
this.resource("item", function () {
this.resource("my-first-item");
this.resource("another-item");
...
});
});
If the user navigates to /item I want to display a specific post (e.g. /item/my-first-item). I can do this by using the redirect method of the route:
App.ItemRoute = Ember.Route.extend({
redirect: function () {
this.transitionTo('my-first-item');
}
});
Unfortunately with this approach if I manually type into the address bar the URL /item/another-item or navigate directly to /item/another-item the app redirects me to /item/my-first-item. If I just change between nested routes (i.e. by clicking a link in the app it loads correctly).
How can I get the redirection to work around only when a nested route has not been provided?