Here is my use case
I have a search model with two actions search_set and search_show.
1 – A user loads the home page which contains a search_form, rendered
via a partial (search_form).
2 – User does a search, and the request goes to search_set, the search
is saved and a redirect happens to search_show page which again
renders the search_form with the saved search preferences. This search
form is different than the one if step1, because it’s a remote form
being submitted to the same action (search set)
3 – Now the user does another search, and the search form is submitted
via ajax to the search_set action. The search is saved and executed
and now I need to present the result via rjs templates (corresponding
to search_show). I am told that if the request is xhr then I can’t
redirect to the search_show action? Is that right? If yes, how do I
handle this?
Here is my controller class
http://pastie.org/993460
Thanks
That’s right. Either make the request non-XHR and redirect as normal, or you could try rendering the URL you want to redirect to as text or part of a JSON object which your AJAX request then uses to call
document.location.href = [whatever](but this seems hacky).Right now what’s happening is your XHR request is returning the result of the redirect, and not actually redirecting the page that made the XHR request.