Hi Darren,
Darren Evans wrote:
I am using form_remote_tag
Then in the controller, under certain conditions I have a redirect_to
This works fine until the redirect_to
I saw your later post. Glad you found a way to make it work. Here's another. But first some explanation.
The key to avoiding the problem you're having is understanding the browser-server request cycle. It starts, always, with the browser. In the request that the browser sends to the server, the browser tells the server, via the message type, what kind of response it expects. The server is free to ignore that and send back anything it wants, but the browser will do with that response what it has told the server it will do. In your case, because you've used form_remote_tag which generates an XMLHttpRequest, the browser has told the server that it expects an executable response. redirect-to doesn't send back an executable (i.e., JS). It sends back straight HTML. The browser gets it, tries to execute it as it told the server that it would, and you end up with nada. By putting the render in the :update option, you've hacked your way into getting the server to send back the JS response the server expects. It's not 'wrong' but that solution won't lead you very far. A more open-ended solution is to use RJS, either in the controller action or in an RJS view. In your case, in the controller, use:
render :update do |page| page.redirect_to(:controller => 'login', :action => 'login') end
hth, Bill