aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/etag_with_flash.rb
blob: f5f9c6267a3ac24a75b7cd9222ef2afdd46ddf55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true
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