From debd774d632ae7e1e6c0a7d0306979159df39b63 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 22 Aug 2016 13:34:35 -0700 Subject: Include the content of the flash in the auto-generated etag (#26250) Include the content of the flash in the auto-generated etag --- .../lib/action_controller/metal/etag_with_flash.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 actionpack/lib/action_controller/metal/etag_with_flash.rb (limited to 'actionpack/lib/action_controller/metal') 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 -- cgit v1.2.3