mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Move Cache::Store config to new initializer
I don't know why but `Rails.logger` is still nil when evaluated from `configure` block in `config/environments/development.rb`. The only way I found to make ActiveSupport's cache to use the default logger is from an initializer. Note that `ActiveSupport::Cache::Store` uses `debug` level and so we need to set the dev logger in that same level to see its messages. If you want to debug in staging as well, you'll need to modify the log level manually.
This commit is contained in:
@@ -9,9 +9,6 @@ Openfoodnetwork::Application.configure do
|
||||
# :file_store is used by default when no cache store is specifically configured.
|
||||
# config.cache_store = :file_store
|
||||
|
||||
# Enable cache instrumentation, which is disabled by default
|
||||
ActiveSupport::Cache::Store.instrument = true
|
||||
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
|
||||
@@ -45,4 +42,6 @@ Openfoodnetwork::Application.configure do
|
||||
# Show emails using Letter Opener
|
||||
config.action_mailer.delivery_method = :letter_opener
|
||||
config.action_mailer.default_url_options = { host: "0.0.0.0:3000" }
|
||||
|
||||
config.log_level = :debug
|
||||
end
|
||||
|
||||
@@ -42,9 +42,6 @@ Openfoodnetwork::Application.configure do
|
||||
# Use a different cache store in production
|
||||
config.cache_store = :dalli_store
|
||||
|
||||
# Enable cache instrumentation, which is disabled by default
|
||||
ActiveSupport::Cache::Store.instrument = true
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
|
||||
7
config/initializers/cache_store.rb
Normal file
7
config/initializers/cache_store.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
unless Rails.env.production?
|
||||
# Enable cache instrumentation, which is disabled by default
|
||||
ActiveSupport::Cache::Store.instrument = true
|
||||
|
||||
# Log message in the same default logger
|
||||
ActiveSupport::Cache::Store.logger = Rails.logger
|
||||
end
|
||||
Reference in New Issue
Block a user