Skip to content

Instantly share code, notes, and snippets.

@andersondias
Created June 28, 2009 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersondias/137184 to your computer and use it in GitHub Desktop.
Save andersondias/137184 to your computer and use it in GitHub Desktop.
Patch to solve bug when using cache_classes = false in development
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index e62cec6..336f7c4 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -221,3 +221,4 @@ require 'active_support/cache/memory_store'
require 'active_support/cache/drb_store'
require 'active_support/cache/mem_cache_store'
require 'active_support/cache/compressed_mem_cache_store'
+require 'active_support/cache/no_store'
diff --git a/activesupport/lib/active_support/cache/no_store.rb b/activesupport/lib/active_support/cache/no_store.rb
new file mode 100644
index 0000000..a9717bd
--- /dev/null
+++ b/activesupport/lib/active_support/cache/no_store.rb
@@ -0,0 +1,11 @@
+module ActiveSupport
+ module Cache
+ class NoStore < Store
+ def read(name, options = nil)
+ super
+ nil
+ end
+ end
+ end
+end
+
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 16abe62..0e617b3 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -773,6 +773,7 @@ Run `rake gems:install` to install the missing gems.
self.database_configuration_file = default_database_configuration_file
self.routes_configuration_file = default_routes_configuration_file
self.gems = default_gems
+ self.cache_store = default_cache_store
self.i18n = default_i18n
for framework in default_frameworks
@@ -979,6 +980,8 @@ Run `rake gems:install` to install the missing gems.
def default_cache_store
if environment != 'test'
if File.exist?("#{root_path}/tmp/cache/")
[ :file_store, "#{root_path}/tmp/cache/" ]
+ elsif environment == 'development'
+ :no_store
else
:memory_store
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment