class ActionDispatch::Flash::FlashHash

def discard(k = nil)

flash.discard(:warning) # discard only the "warning" entry at the end of the current action
flash.discard # discard the entire flash at the end of the current action

Marks the entire flash or a single flash entry to be discarded by the end of the current action:
def discard(k = nil)
  k = k.to_s if k
  @discard.merge Array(k || keys)
  k ? self[k] : self
end