diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 2674fe068049fea7e8f9b6ccf949df26bcdb83a2..28eef311fd9c2cafd079785c67b5ff46af442ba9 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Don't put flash in session if sessions are disabled. [Jeremy Kemper] + * Strip out trailing &_= for raw post bodies. Closes #2868. [Sam Stephenson] * Pass multiple arguments to Element.show and Element.hide in JavaScriptGenerator instead of using iterators. [Sam Stephenson] diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb index 06c8c4b5c6bdfc2bf7c38ff5fc7f2c2a23bd5d3b..9eac5784fd4f0e0960c83502f2e2cef0548f00c1 100644 --- a/actionpack/lib/action_controller/flash.rb +++ b/actionpack/lib/action_controller/flash.rb @@ -132,22 +132,31 @@ def use(k=nil, v=true) end end end - - + + protected # Access the contents of the flash. Use flash["notice"] to read a notice you put there or # flash["notice"] = "hello" to put a new one. + # Note that if sessions are disabled only flash.now will work. def flash #:doc: - @session['flash'] ||= FlashHash.new + # @session = Hash.new if sessions are disabled + if @session.is_a?(Hash) + @__flash ||= FlashHash.new + + # otherwise, @session is a CGI::Session or a TestSession + else + @session['flash'] ||= FlashHash.new + end end - + # deprecated. use flash.keep instead def keep_flash #:doc: + warn 'keep_flash is deprecated; use flash.keep instead.' flash.keep end - - - private + + + private # marks flash entries as used and expose the flash to the view def fire_flash