Skip to content

Instantly share code, notes, and snippets.

@andersondias
Created June 30, 2009 15:10
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/138212 to your computer and use it in GitHub Desktop.
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.
# 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