0
votes

I've been doing a ton of reading on the way that flash[]= works in rails and understand that when you redirect_to, to use the flash[...]=..., and if you are rendering the action after assignment, then flash.now[...]...; however, my application's flash is persisting indefinitely, never actually going away during the session.

This question is a hypothetical. If I have a controller,

class MyController < ApplicationController
  def index
    if my_cond 
      flash.now[:notice] = "Your condition is true"
    else
      flash[:notice] = "Your condition isn't true"
      redirect_to some_other_rendering_action
    end
  end
end

If I redirect this time, then the next time I redirect, let's say via clicking a link that connects to some action that redirects to another render, but leaves flash unmodified, then it renders the flash. The problem is this happens indefinitely, doesn't even end after one redirect.

How would you suggest troubleshooting this issue? The application is probably 35k lines, and already has been washed to follow the flash and flash.now solution recommendations posted everywhere, so where do we look?

rails 2.3.5 high volume site, apache/mongrel

ADDING INFORMATION:

The flash is persisting in the session as well.

flash: !map:ActionController::Flash::FlashHash 
  :notice: You must be signed in to view this page.
1

1 Answers

1
votes

I suggest looking for flash.keep calls and if you have no luck and want to get rid of the behavior, add an after_filter that calls flash.discard to your ApplicationController

class ApplicationController < ActionController::Base
  after_filter :discard_flash
  private
  def discard_flash
    flash.discard
  end
end