Escaping the AJAX View


#1

I have a login form, in which I use a “form_remote_tag”.
I’m redirecting users to this form when they fail authentication as
well…
and using the “jumpto” method of capturing they
original URL they requested via request.parameters, and redirecting to
this
URL after they authenticate.

Problem is, if I try to do a “redirect_to”, this won’t work, as I’m
still in
the AJAX request.

I’m assuming my only alternatives are:

  1. Not use AJAX
  2. Send un-authenicated users to a different non-ajaxed login form.
  3. Parse the request.parameters, then pass the URL as a variable into a
    template which then does a window.location redirect.

Any other ideas ?


#2

^bump^


#3

You can use RJS to redirect the user. In the action you can do…

render :update do |page|
page.redirect_to :action => :my_action
end

-Jonny.

Dylan S. wrote:

^bump^


#4

Genius, thanks Jonathan :slight_smile:
My fear of RJS templates has been vanquished ! Edge demons be gone !!

It took me literally 10 minutes to switch out a complex form over to
RJS.
It works perfectly now.

Thank you, thank you, thank you :slight_smile:


#5

No problem. RJS is a very powerful tool.

-Jonny.

Dylan S. wrote:

Thank you, thank you, thank you :slight_smile: