From bf697cef7bc2c5f7771e5eb26e80c5e787833fca Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 27 Jun 2013 00:00:37 -0700 Subject: [PATCH] expire item#as_json when updated --- app/models/fragment_expiration.rb | 7 +++++++ app/models/item_observer.rb | 1 + 2 files changed, 8 insertions(+) diff --git a/app/models/fragment_expiration.rb b/app/models/fragment_expiration.rb index f124c8c2..1f312829 100644 --- a/app/models/fragment_expiration.rb +++ b/app/models/fragment_expiration.rb @@ -9,6 +9,13 @@ module FragmentExpiration expire_fragment(localized_key) end end + + def expire_key_in_all_locales(key) + I18n.available_locales.each do |locale| + localized_key = localize_fragment_key(key, locale) + Rails.cache.delete(localized_key) + end + end private diff --git a/app/models/item_observer.rb b/app/models/item_observer.rb index 820a817a..ee68cc30 100644 --- a/app/models/item_observer.rb +++ b/app/models/item_observer.rb @@ -22,6 +22,7 @@ class ItemObserver < ActionController::Caching::Sweeper expire_fragment_in_all_locales("items/#{item.id}#item_link_partial") expire_fragment_in_all_locales("items/#{item.id} header") expire_fragment_in_all_locales("items/#{item.id} info") + expire_key_in_all_locales("items/#{item.id}#as_json") end def expire_newest_items