Is there a way to redirect the page through a ajax request. I tried
using link_to_remote tag as the logout link on a page and used the
'redirect_to index' in the called method. But I get the whole page in
the request.reponseText as normal text and the browser page doesn't
change.
Is there a way to redirect the page through a ajax request. I tried
using link_to_remote tag as the logout link on a page and used the
'redirect_to index' in the called method. But I get the whole page in
the request.reponseText as normal text and the browser page doesn't
change.
Just send JS that sets the window.location:
render :update do |rjs|
rjs << "window.location = #{ url_for something };"
end
I wrote 'rjs' where everyone else writes 'page' because that was a bad
idea for a variable name. There are way too many variables out there
called 'page'!
NameError
in LoginController#logout
</h1>
<pre>undefined local variable or method `page' for
#<LoginController:0x7f2950c0></pre>
<p><code>RAILS_ROOT: script/../config/..</code></p>
i've added it like this in my LoginController#logout method
def logout
session[:sess].sign_out
page.redirect_to "index"
end
NameError
in LoginController#logout
</h1>
<pre>undefined local variable or method `page' for
#<LoginController:0x7f2950c0></pre>
<p><code>RAILS_ROOT: script/../config/..</code></p>
i've added it like this in my LoginController#logout method
def logout
session[:sess].sign_out
page.redirect_to "index"
end
Read up on rjs. page is the name usually given to the instance of
javascript generator you use. If you have an rjs template it will be
defined in there. If you have a render :update then it is the thing
that is yielded to the block. Either plonk it in logout.rjs or do
some pike
render :update do |page|
...
end