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] -%> <p class="errorAlert">Your session expired. Please login to start again.</p> <% 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 -- Posted via http://www.ruby-forum.com/.
Make sure you have: <%= flash[:notice] %> .. in your view else no flash notice will display. -- Posted via http://www.ruby-forum.com/.
On Jul 29, 12:40 am, Greg Willits <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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> > -- gw > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Jul 29, 12:40�am, Greg Willits <rails-mailing-l...@andreas-s.net> > 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 thatYeah 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] -%> <p class="errorAlert">Your session expired....</p> <% 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 -- Posted via http://www.ruby-forum.com/.