How to display a Rails flash notice upon redirect?

rails-flash, ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.2, ruby-on-rails-4

Solution

Remove the `.now`. So just write:

flash[:notice] = 'Successfully checked in'
redirect_to check_in_path

The `.now` is specifically supposed to be used when you are just rendering and not redirecting. When redirecting, the `.now` is not to be used.

Problem

I have the following code in a Rails controller: ``` flash.now[:notice] = 'Successfully checked in' redirect_to check_in_path ``` Then in the /check_in view: ``` <p id="notice"><%= notice %></p> ``` However, the notice does not show up. Works perfect if I don't redirect in the controller: ``` flash.now[:notice] = 'Successfully checked in' render action: 'check_in' ``` I need a redirect though... not just a rendering of that action. Can I have a flash notice after redirecting?

Original source