How to display a Rails flash notice upon redirect?
Solution 1:
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.
Solution 2:
redirect_to new_user_session_path, alert: "Invalid email or password"
in place of :alert
you can use :notice
to display
Solution 3:
Or you can do it in one line.
redirect_to check_in_path, flash: {notice: "Successfully checked in"}
Solution 4:
This will work too
redirect_to check_in_path, notice: 'Successfully checked in'