aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-03-17 16:19:12 -0400
committerJon Moss <me@jonathanmoss.me>2016-03-19 21:52:45 -0400
commit6c6a22176f01b563a7b731fee9f37c837ba83320 (patch)
tree988c98e2cce707f0b554e8cbce14dfa871e43dae /actionpack
parent47c0a3990a44bbf678e06605eb77f000147dac70 (diff)
downloadrails-6c6a22176f01b563a7b731fee9f37c837ba83320.tar.gz
rails-6c6a22176f01b563a7b731fee9f37c837ba83320.tar.bz2
rails-6c6a22176f01b563a7b731fee9f37c837ba83320.zip
Fix request.reset_session for API controllers
Due to that `ActionDispatch::Flash` (the flash API's middleware) is not included for API controllers, the `request.reset_session` method, which relies on there being a `flash=` method which is in fact defined by the middleware, was previously breaking. Similarly to how add46482a540b33184f3011c5c307f4b8e90c9cc created a method to be overridden by the flash middleware in order to ensure non-breakage, this is how flashes are now reset. Fixes #24222
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb1
-rw-r--r--actionpack/lib/action_dispatch/middleware/flash.rb5
2 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 316a9f08b7..b0ed681623 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -337,7 +337,6 @@ module ActionDispatch
else
self.session = {}
end
- self.flash = nil
end
def session=(session) #:nodoc:
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb
index c51dcd542a..06038af571 100644
--- a/actionpack/lib/action_dispatch/middleware/flash.rb
+++ b/actionpack/lib/action_dispatch/middleware/flash.rb
@@ -70,6 +70,11 @@ module ActionDispatch
session.delete('flash')
end
end
+
+ def reset_session # :nodoc
+ super
+ self.flash = nil
+ end
end
class FlashNow #:nodoc: