diff --git a/app/controllers/alchemy/pages_controller.rb b/app/controllers/alchemy/pages_controller.rb index d92f4e4ea8..2cfd43f2e1 100644 --- a/app/controllers/alchemy/pages_controller.rb +++ b/app/controllers/alchemy/pages_controller.rb @@ -218,12 +218,13 @@ def signup_required? # # IMPORTANT: # - # If your user does not have a +cache_key+ method (i.e. it's not an ActiveRecord model), + # If your user does not have a +cache_key_with_version+ method (i.e. it's not an ActiveRecord model), # you have to ensure to implement it and return a unique identifier for that particular user. # Otherwise all users will see the same cached page, regardless of user's state. # def page_etag - @page.cache_key + current_alchemy_user.try(:cache_key).to_s + @page.cache_key_with_version + + current_alchemy_user.try(:cache_key_with_version).to_s end # We only render the page if either the cache is disabled for this page diff --git a/spec/controllers/alchemy/pages_controller_spec.rb b/spec/controllers/alchemy/pages_controller_spec.rb index 269b9de607..74e3a71adf 100644 --- a/spec/controllers/alchemy/pages_controller_spec.rb +++ b/spec/controllers/alchemy/pages_controller_spec.rb @@ -273,7 +273,7 @@ module Alchemy subject { controller.send(:page_etag) } before do - expect(page).to receive(:cache_key).and_return("aaa") + expect(page).to receive(:cache_key_with_version).and_return("aaa") controller.instance_variable_set("@page", page) end @@ -283,7 +283,7 @@ module Alchemy context "with user logged in" do before do - authorize_user(mock_model(Alchemy.user_class, cache_key: "bbb")) + authorize_user(mock_model(Alchemy.user_class, cache_key_with_version: "bbb")) end it "returns another etag for response headers" do