diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2016-08-22 13:34:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-22 13:34:35 -0700 |
commit | debd774d632ae7e1e6c0a7d0306979159df39b63 (patch) | |
tree | 743d98e205e426284db8b823ad4cd133188c96e0 /actionpack/lib | |
parent | 3bfd35245278f410bb2165e859f1cfeb352e0d77 (diff) | |
download | rails-debd774d632ae7e1e6c0a7d0306979159df39b63.tar.gz rails-debd774d632ae7e1e6c0a7d0306979159df39b63.tar.bz2 rails-debd774d632ae7e1e6c0a7d0306979159df39b63.zip |
Include the content of the flash in the auto-generated etag (#26250)
Include the content of the flash in the auto-generated etag
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/etag_with_flash.rb | 16 |
3 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index fc86a907b3..50f20aa789 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -23,6 +23,7 @@ module ActionController autoload :Cookies autoload :DataStreaming autoload :EtagWithTemplateDigest + autoload :EtagWithFlash autoload :Flash autoload :ForceSSL autoload :Head diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 68a526eccb..ca8066cd82 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -213,6 +213,7 @@ module ActionController Renderers::All, ConditionalGet, EtagWithTemplateDigest, + EtagWithFlash, Caching, MimeResponds, ImplicitRender, diff --git a/actionpack/lib/action_controller/metal/etag_with_flash.rb b/actionpack/lib/action_controller/metal/etag_with_flash.rb new file mode 100644 index 0000000000..474d75f02e --- /dev/null +++ b/actionpack/lib/action_controller/metal/etag_with_flash.rb @@ -0,0 +1,16 @@ +module ActionController + # When you're using the flash, it's generally used as a conditional on the view. + # This means the content of the view depends on the flash. Which in turn means + # that the etag for a response should be computed with the content of the flash + # in mind. This does that by including the content of the flash as a component + # in the etag that's generated for a response. + module EtagWithFlash + extend ActiveSupport::Concern + + include ActionController::ConditionalGet + + included do + etag { flash unless flash.empty? } + end + end +end |