I am using Rails 3.1.0 and I would like to understand why the following code in a controller action doesn’t properly display the flash[:warning] message even if I state a <%= content_tag( :div, flash[:warning]) %> in the application.html.erb file.
flash[:warning] = "Warning message!"
respond_to do |format|
format.html { redirect_to :root }
end
Why the flash[:warning] message is not displayed? How can I display that after redirection?
P.S. I: I tryed to use flash.keep[:warning] but that didn’t work.
SOLUTION
The problem is that I am redirecting two times in my controller actions.
P.S. II: Who voted down can at least give some reasons…
Have you written this line in your layout/view? If not then write this code in your layout file