Occasionally you’ll redirect a user in Ember silently
based on some condition instead of them taking an action (like clicking
a link). In that case,
you don’t want to pollute their browser history, as hitting ‘back’
button would kick them into a loop.
This is frustratingly common in applications that manipulate the history
API and can cause confusion for the user.
Ember has a good method for dealing with this. For those “silent”
transitions that will trigger based on a condition, use replaceRoute
instead of transitionToRoute.
Here’s an example route that demonstrates how to use it. This assumes
that you have Post that has a draft attribute telling the application
to only show it to authenticated users.
The replaceRoute method won’t create a history entry, avoiding a redirect