How to display a Rails flash notice upon redirect?
问题 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? 回答1: Remove the .now . So just write: