Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How To Escape From AJAX URL

DZone's Guide to

How To Escape From AJAX URL

·
Free Resource
From Dylan Stamat's post on the Ruby on Rails list 	


Within my "login.rjs" template that get's invoked after my login process, it returns to the same page with an error message on error, or... if the login was successful, it needs to "redirect" to another controller... which is pretty much impossible to do otherwise.  so, my " login.rjs" looks like:


if @logged_in_client
  page.replace_html "message", :partial => 'shared/bad_login'
else
  page.redirect_to "whatever you want here"
end

------ End Message--------
Here is my two cents:
Technically, you can do this without a RJS template at all, because it is such a simple example. Use this in your controller


render :update do |page|
  if @logged_in_client
    page.replace_html "message", :partial => 'shared/bad_login'
  else
    page.redirect_to "whatever you want here"
  end
end
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}