I have a create method in one controller and at the end of this controller I want redirect_to another controller/view. How will I be able to display a flash[:notice] after the first controller is done and the next redirect_to view is rendered?
Here’s the code in the first controller:
if @list.save
redirect_to root_path, :notice => "Created!"
I also noticed that it doesn’t work here either:
if @list.save
redirect_to root_path, :alert => "Created!"
Here’s the routes file:
root :to => 'sessions#new'
To persist a flash message over an additional request you can use
flash.keep– from the flash section on Rails Guides:Clarification: This solution only applies if you’re losing the flash due to a double redirect.