Rails: cache_classes => false still caches

2019-09-19 16:39发布

It seems like cache_classes => false still caches them, and I have to shut down and restart the server to see any changes. Any ideas? I'm really stuck, and it's a very annoying problem.

My development.rb looks like this:

Total::Application.configure do
  config.cache_classes = false
  config.whiny_nils = true
  config.threadsafe!
  # Add the fonts path
  config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
  # Precompile additional assets
  config.assets.precompile += %w( .svg .eot .woff .ttf )
  config.serve_static_assets = true
  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  # config.eager_load = false
  config.action_mailer.default_url_options = { :host => 'lvh.me:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default :charset => "utf-8"
  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com" # ETC
  }
  config.active_support.deprecation = :log
  config.action_dispatch.best_standards_support = :builtin
  config.active_record.mass_assignment_sanitizer = :strict
  config.assets.compress = false
  config.assets.debug = true
end

Any help would be great. Thanks.

1条回答
家丑人穷心不美
2楼-- · 2019-09-19 16:47

If anyone else has this problem the solution was the order: config.threadsafe! has to come before config.cache_classes. Reorder it like this to fix it:

...
config.threadsafe!
config.cache_classes = false
...

Update

It's simply because config.threadsafe! does this:

def threadsafe!
  @preload_frameworks = true
  @cache_classes      = true
  @dependency_loading = false
  @allow_concurrency  = true
  self
end

See here for what thread safety does.

查看更多
登录 后发表回答