redirect_to doesn't create history

I have a wizard type flow where on each screen clicking the "continue" button posts data to the server, then I use redirect_to to show the main wizard page (which dynamically shows partials based on the current state). The oddity I'm seeing - and maybe it's just an HTTP thing - is that when these redirects happen, there is NO entry in the browser history - not even for the page that was redirected to. So, if this happens:

     GET /wizard (on "page 1" here)      POST /wizard (form filled in on "page 1" is processed here, model's page parameter changed to "2", then I do a redirect_to wizard_url)      GET /wizard (on "page 2" here because the model had it's page number changed)

What I see in history is the initial entry for wizard and that's it. So if a user is on page 2 (or 3 or 4 or whatever) and hits their back button, they go back to whatever page was displayed before they first started the wizard.

Is there a special HTTP code I can set using the :status parameter to force it to put ALL of the GET requests in the history (even the ones initiated by redirect)?

Thanks for any help.


There might be, but I haven't heard of it. What your describing actually makes sense. A redirect implies the page is now elsewhere. So why save it in the history? That is...

GET /some-page (in history) GET /some-old-url (results in redirect to /some-new-url) GET /some-new-url (in history)

Why, normally would you want to see that second request in your browser history?

I don't know how you have your app setup, but instead of redirecting, what about sending back an almost empty page containing just enough javascript or meta-refresh to take you to the next page.


Thanks for the reply. You're correct - and in your example I'd expect to see the following in history:

   * /some-page    * /some-new-url

That's not exactly what I was describing though. In my case, think of it as /some-old-url actually redirecting to /some-page instead of / some-new-url. Since the browser sees a redirect to /some-page - which is the same url it's already on - it seems to say "ok, I didn't go anywhere" and not change the history at all. So in the history I only have:

   * /some-page

From a browser standpoint, this makes since because it doesn't know that /some-page is dynamically generated based on state saved in a DB.

This question really arose from me trying to keep a single URL for every page in the wizard and just display whatever step the user was actually on. After thinking about the problem for a bit, I decided that each wizard step is actually a different page and needs it's own URL - it didn't really make sense to do what I was doing. This solved the problem completely for me since with different URLs the history is working the way I'd expect - and code got a lot cleaner too!