Forum: Ruby on Rails escaping from Ajax in 1.2.1

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeff P. (Guest)
on 2007-01-31 04:53
Way back in the old days (Rails 1.1.6), you could go from an ajax form
back to the real world by doing something like this:

render :update do |page|
  page.redirect_to(:controller => 'foo', :action => 'bar')
end

I just upgraded my in-progress app to 1.2.1, and this seems to be broken
now.  I get the dreaded old "redirection script showing up in the
browser" thing happening, which is what this rjs snippet was supposed to
fix (and used to do).

Is this no longer the proper way to redirect out of Ajax land?  Or did I
just mess up in some other way and weakly blame this on 1.2.1?

thanks,
jp
Alex W. (Guest)
on 2007-01-31 07:47
Jeff P. wrote:
> Way back in the old days (Rails 1.1.6), you could go from an ajax form
> back to the real world by doing something like this:
>
> render :update do |page|
>   page.redirect_to(:controller => 'foo', :action => 'bar')
> end
>
> I just upgraded my in-progress app to 1.2.1, and this seems to be broken
> now.  I get the dreaded old "redirection script showing up in the
> browser" thing happening, which is what this rjs snippet was supposed to
> fix (and used to do).
>
> Is this no longer the proper way to redirect out of Ajax land?  Or did I
> just mess up in some other way and weakly blame this on 1.2.1?
>
> thanks,
> jp

Make sure that your ajax call doesn't have an :update key in it.  If it
does, your javascript will be rendered as text since it's not wrapped in
a <script> tag.

If this is the problem than rails 1.2 is not to blame since I ran into
that in 1.1.6
This topic is locked and can not be replied to.