In my save function in my (ajax!!!) controller, i''ve got a bit like this: if ... flash[:notice] = ''NOT SAVED: This month is locked'' render :partial => ''edit'' else save it... redirect to ''show'' action.... ... If i try to save an entry for a locked month, it correctly brings me back to my edit action with the ''not saved'' message correctly showing. But if i then go to another page, the ''not saved'' message still shows! But then if i refresh, it disappears. It seems the flash notice sticks around one too many page views. Any Ideas? -- Posted via http://www.ruby-forum.com/.
chris hulbert
2006-Feb-20 23:59 UTC
[Rails] Re: Problem with flash[:notice] appearing twice
Bingo - sorted it myself! Put this in the application controller: before_filter :remove_flash_notice private def remove_flash_notice #flash[:notice] = '''' true end Isn''t this a bit of an oversight, though? Or am i missing something? -- Posted via http://www.ruby-forum.com/.
Kent Sibilev
2006-Feb-21 03:47 UTC
[Rails] Re: Problem with flash[:notice] appearing twice
Yes, you are missing the fact that you should use flash[:something] = value only if you intend to redirect_to another action. Otherwise you''re better of using flash.now[:something] = value -- Kent --- http://www.datanoise.com On 2/20/06, chris hulbert <chris.hulbert@ruralpress.com> wrote:> Bingo - sorted it myself! > > Put this in the application controller: > > before_filter :remove_flash_notice > > private > def remove_flash_notice > #flash[:notice] = '''' > true > end > > > Isn''t this a bit of an oversight, though? Or am i missing something? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >