From 26b92c164d91abc444031e66bd6459bf9b94e68e Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Tue, 22 Jun 2010 14:52:53 +1200 Subject: [PATCH] Don't cache when there's no pages --- .../plugins/refinery/lib/refinery/application_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vendor/plugins/refinery/lib/refinery/application_controller.rb b/vendor/plugins/refinery/lib/refinery/application_controller.rb index 1bae2b3851..a9771c6b47 100644 --- a/vendor/plugins/refinery/lib/refinery/application_controller.rb +++ b/vendor/plugins/refinery/lib/refinery/application_controller.rb @@ -61,8 +61,10 @@ def login? # get all the pages to be displayed in the site menu. def find_pages_for_menu - @menu_pages = Rails.cache.read(cache_key = "#{Refinery.base_cache_key}_menu_pages") - @menu_pages = Rails.cache.write(cache_key, Page.top_level(include_children=true)) if @menu_pages.nil? + if (@menu_pages = Rails.cache.read(cache_key = "#{Refinery.base_cache_key}_menu_pages")).nil? + @menu_pages = Page.top_level(include_children = true) + Rails.cache.write(cache_key, @menu_pages) if @menu_pages.present? + end end # use a different model for the meta information.