Topic: redirect_to :back (without params)

I'm using a select menu to reset a session var, then redirect back. But it's possible for GET params in the previous URL to force an 'undo' of the change that was just made to the session var, which is not what I want.

So, I specifically want to be able to redirect to the last page while stripping the GET params from the :back page. Is there a way to pass options to the :back call?

Passing the action_name and controller_name as hidden fields into the session-changing def is possible, but I'm wondering if there's a more elegant solution.


Re: redirect_to :back (without params)


There is no way to pass options to the :back call.

With that said, you may be able to mangle something into working.  :back is a shortcut for:

request.env["HTTP_REFERER"] ? redirect_to(request.env["HTTP_REFERER"]) : raise(RedirectBackError)

You may take a look at some of the other variables available as part of the request, or possibly stripping HTTP_REFERER.

Ruby Rockstars - Ruby Jobs for all!

Re: redirect_to :back (without params)

Thanks, jdg, I'll check into that.