hi all, using rails 1.2.3 on windows xp i have a controller method like so: def index ...do stuff... if some_error flash[:notice] = "error!" end end and the layout has: <% if flash[:notice] -%> <div class="flash"><%= flash[:notice] %></div> <% end -%> the form for index submits via GET method. if i cause the some_error condition through the form, i get the flash message as expected. however, if i immediately submit again with conditions that do not cause some_error, i still get the flash message again. it takes until submitting a third time for the flash message to clear. isn''t it supposed to clear itself after it renders the first time in the layout? i know i''m not setting it again because i have a debug statement when it gets set in the controller. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ok, nevermind - i RTFM: http://api.rubyonrails.org/classes/ActionController/Flash/FlashHash.html the method flash.now[:message] = "Hello current action" is supposed to be used when rendering the current action; flash[:notice] = ''some message'' is to be used when using redirect_to --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What you describes maps with my understanding of flash. From ActiveController:Flash: "Anything you place in the flash will be exposed to the very next action and then cleared out." I think what you want is flash.now: flash.now[:notice] = "error!" - Hal jemminger wrote:> hi all, > > using rails 1.2.3 on windows xp > > i have a controller method like so: > > def index > ...do stuff... > if some_error > flash[:notice] = "error!" > end > end > > and the layout has: > <% if flash[:notice] -%> > <div class="flash"><%= flash[:notice] %></div> > <% end -%> > > the form for index submits via GET method. if i cause the some_error > condition through the form, i get the flash message as expected. > however, if i immediately submit again with conditions that do not > cause some_error, i still get the flash message again. it takes until > submitting a third time for the flash message to clear. isn''t it > supposed to clear itself after it renders the first time in the > layout? i know i''m not setting it again because i have a debug > statement when it gets set in the controller.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yep - just saw that in the docs too. thanks for the reply! On May 1, 9:58 am, Hal <hburch.ra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What you describes maps with my understanding of flash. From > ActiveController:Flash: "Anything you place in the flash will be > exposed to the very next action and then cleared out." > > I think what you want is flash.now: > flash.now[:notice] = "error!" > > - Hal > > jemminger wrote: > > hi all, > > > using rails 1.2.3 on windows xp > > > i have a controller method like so: > > > def index > > ...do stuff... > > if some_error > > flash[:notice] = "error!" > > end > > end > > > and the layout has: > > <% if flash[:notice] -%> > > <div class="flash"><%= flash[:notice] %></div> > > <% end -%> > > > the form for index submits via GET method. if i cause the some_error > > condition through the form, i get the flash message as expected. > > however, if i immediately submit again with conditions that do not > > cause some_error, i still get the flash message again. it takes until > > submitting a third time for the flash message to clear. isn''t it > > supposed to clear itself after it renders the first time in the > > layout? i know i''m not setting it again because i have a debug > > statement when it gets set in the controller.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---