rails 3 + jquery + ajax - dont discard flash upon ajax request which redirects
Normally, I call flash.discard if my request is xhr. I do this as an after filter in the application controller.
However开发者_如何学Go, I dont want to call flash.discard in the event that I have an ajax call which sets a flash and then redirects to another page.
How do I achieve this?
If I understood it right, you need to know if a response is a redirect. Create an after filter in application controller to check the response status.
after_filter :discard_flash_message
def discard_flash_message
if request.xhr? and response.status == :found
//do not call flash.discard
end
end
精彩评论