From 5fe6317931ab616f8865d6004fa4a82bd52a3ff6 Mon Sep 17 00:00:00 2001 From: lg2046 Date: Thu, 2 May 2013 10:38:33 +0800 Subject: [PATCH 1/4] disable hash one through association --- lib/second_level_cache/active_record/has_one_association.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/second_level_cache/active_record/has_one_association.rb b/lib/second_level_cache/active_record/has_one_association.rb index 211a438..34c1742 100644 --- a/lib/second_level_cache/active_record/has_one_association.rb +++ b/lib/second_level_cache/active_record/has_one_association.rb @@ -12,6 +12,7 @@ module HasOneAssociation def find_target_with_second_level_cache return find_target_without_second_level_cache unless association_class.second_level_cache_enabled? + return find_target_without_second_level_cache if self.class == ::ActiveRecord::Associations::HasOneThroughAssociation cache_record = association_class.fetch_by_uniq_key(owner[reflection.active_record_primary_key], reflection.foreign_key) return cache_record.tap{|record| set_inverse_instance(record)} if cache_record From e8c688968a6cb9a923c7812119ce834b477a1e5f Mon Sep 17 00:00:00 2001 From: lg2046 Date: Thu, 2 May 2013 10:49:07 +0800 Subject: [PATCH 2/4] Respect to system config --- lib/second_level_cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/second_level_cache.rb b/lib/second_level_cache.rb index 989ebc8..e342ca8 100644 --- a/lib/second_level_cache.rb +++ b/lib/second_level_cache.rb @@ -26,7 +26,7 @@ def acts_as_cached(options = {}) end def second_level_cache_enabled? - !!@second_level_cache_enabled + !!@second_level_cache_enabled && Rails.application.config.cache_classes end def without_second_level_cache From 391a797507ed70dc4650f475aeefb7affdb0470f Mon Sep 17 00:00:00 2001 From: lg2046 Date: Thu, 2 May 2013 11:00:21 +0800 Subject: [PATCH 3/4] namespace error --- lib/second_level_cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/second_level_cache.rb b/lib/second_level_cache.rb index e342ca8..2e2f7a7 100644 --- a/lib/second_level_cache.rb +++ b/lib/second_level_cache.rb @@ -26,7 +26,7 @@ def acts_as_cached(options = {}) end def second_level_cache_enabled? - !!@second_level_cache_enabled && Rails.application.config.cache_classes + !!@second_level_cache_enabled && ::Rails.application.config.cache_classes end def without_second_level_cache From a33528eccc83b8418e45b8355d6ba4987f5d8839 Mon Sep 17 00:00:00 2001 From: lg2046 Date: Thu, 2 May 2013 11:04:10 +0800 Subject: [PATCH 4/4] Travis build --- lib/second_level_cache.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/second_level_cache.rb b/lib/second_level_cache.rb index 2e2f7a7..c069c70 100644 --- a/lib/second_level_cache.rb +++ b/lib/second_level_cache.rb @@ -26,7 +26,11 @@ def acts_as_cached(options = {}) end def second_level_cache_enabled? - !!@second_level_cache_enabled && ::Rails.application.config.cache_classes + if defined?(Rails) + !!@second_level_cache_enabled && ::Rails.application.config.cache_classes + else + !!@second_level_cache_enabled + end end def without_second_level_cache