diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/flash.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/flash.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index 6f97c06b6b..bc5b163931 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -4,7 +4,7 @@ module ActionDispatch # read a notice you put there or <tt>flash["notice"] = "hello"</tt> # to put a new one. def flash - @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new).tap(&:sweep) + @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new) end end @@ -235,6 +235,10 @@ module ActionDispatch end def call(env) + if (session = env['rack.session']) && (flash = session['flash']) + flash.sweep + end + @app.call(env) ensure session = env['rack.session'] || {} @@ -251,8 +255,7 @@ module ActionDispatch env[KEY] = new_hash end - if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) - session.key?('flash') && session['flash'].empty? + if session.key?('flash') && session['flash'].empty? session.delete('flash') end end |