Rails Flash.now not working

Manjunath Manoharan picture Manjunath Manoharan · Aug 20, 2011 · Viewed 29.9k times · Source

I have a view from which I make an ajax request to the controller and after the action is successfully completed I initialize the flash.now[:notice]. But after the control goes back to the view. I don't happen to see the flash message.

flash.now[:notice] = "Request Completed successfully" if @meetings.any?

Answer

AJP picture AJP · Aug 20, 2011

When redirecting use

flash[:notice] = "This message value is available in next request-response cycle"

When rendering use

flash.now[:notice] = "Message is available in same request-response cycle"

Info from here