Created
June 30, 2009 15:10
-
-
Save andersondias/138212 to your computer and use it in GitHub Desktop.
This monkey patch intends to solve cache errors on development environment when config.cache_classes = false.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Authors: Anderson Dias (andersondias.github.com) and João Vitor (joaovitor.github.com) | |
# This monkey patch intends to solve cache errors on development environment when config.cache_classes = false. | |
# In order to use it you need to put it into you lib/ folder and | |
# insert "require File.join(RAILS_ROOT, 'lib', 'no_store_cache_monkey_patch')" | |
# after the "require File.join(File.dirname(__FILE__), 'boot')" line in config/environment.rb: | |
module ActiveSupport | |
module Cache | |
class NoStore < Store | |
def read(name, options = nil) | |
super | |
nil | |
end | |
end | |
end | |
end | |
module Rails | |
class Configuration | |
class << self | |
alias :old_initialize :initialize | |
end | |
def initialize | |
raise 'deu pau' | |
self.old_initialize | |
self.cache_store = default_cache_store | |
end | |
private | |
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 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment