Flash stopped working

I had a working 1.2 app now being updated to 2.3. I’m using a flash
message which has worked fine. After the update to 2.3, the message no
longer displays when it should.

In application_controller.rb, I do a simple conditional to see if a
session has expired (time based). If it has, I reset_session, set a
flash message, and redirect_to the login page.

if — conditionals—
reset_session
flash[:session_expired] = true
redirect_to(:controller => :login, :action => :login)
return false
end

And the view uses a straightforward snippet:

<% if flash[:session_expired] -%>

Your session expired. Please login to start again.

<% end -%>

And using <%= debug(flash) %> display an empty hash.

This just seems too simple to not work, and it worked just fine with
Rail 1.2.

Has something changed? Somethig that didn’t interfere and reset the
flash in 1.2 that now does?

– gw

Make sure you have:

<%= flash[:notice] %>

… in your view else no flash notice will display.

On Jul 29, 12:40 am, Greg W. [email protected]
wrote:

And using <%= debug(flash) %> display an empty hash.

This just seems too simple to not work, and it worked just fine with
Rail 1.2.

Has something changed? Somethig that didn’t interfere and reset the
flash in 1.2 that now does?

Session handling has changed (several times) between 1.2 and 2.3. I
think the key thing here is likely to be the fact that you’re calling
reset session and that the flash is stored in the session. I’d check
the cookies going back and forth between the browser and your app to
see exactly what is going on right now (maybe something odd like the
flash object still being in the session object that is being dumped
rather than the new one or something like that

Fred

Frederick C. wrote:

On Jul 29, 12:40�am, Greg W. [email protected]
wrote:

And using <%= debug(flash) %> display an empty hash.

This just seems too simple to not work, and it worked just fine with
Rail 1.2.

Has something changed? Somethig that didn’t interfere and reset the
flash in 1.2 that now does?

Session handling has changed (several times) between 1.2 and 2.3. I
think the key thing here is likely to be the fact that you’re calling
reset session and that the flash is stored in the session. I’d check
the cookies going back and forth between the browser and your app to
see exactly what is going on right now (maybe something odd like the
flash object still being in the session object that is being dumped
rather than the new one or something like that

Yeah this is real weird to me. I added log lines at various steps to see
what was happening

if — conditionals—
# A
reset_session
# B
flash[:session_expired] = true
# C
redirect_to(:controller => :login, :action => :login)
# E
return false
end

<% # D %>
<% if flash[:session_expired] -%>

Your session expired....

<% end -%>

#A = full session data
#B = session is empty
#C = session has the flash I am expecting
#D = session is empty
#E = session has the flash I am expecting

So, there’s some rather unintuitive order of operations going on here it
looks like.

I guess I’ll hack it some other way.

– gw

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs