Alex Rivera | Logout

Flash message in redirect not working

Asked 2011-09-15T06:08:13.520
30

I have the following in my controller:

redirect_to signin_path, :notice => "The email is already registered"

In my view I have

<%= flash[:notice] if flash[:notice] %>

But the flash message does not appear.

However if I do the following in the controller

flash[:notice] = "There is already an acount for this email. Please Login to create your board."
redirect_to signin_path

It does work. What is the reason the first one does not work?

Edit
Report

1 Answer

6

simple, but effective:

modify ApplicationController < ActionController::Base as follows:

alias :std_redirect_to :redirect_to
def redirect_to(*args)
   flash.keep
   std_redirect_to *args
end
answered 2012-02-15T18:28:18.267

Your Answer