From b2800ca94421950d0f6d057509a74176bd15e543 Mon Sep 17 00:00:00 2001 From: Mike Patrick Date: Mon, 20 Jan 2025 16:05:56 +0000 Subject: [PATCH] Update some more config following Rails 8 upgrade Here are some updates to a handful of config settings that I didn't spend enough time looking into when I ran `rails app:update` the other day following the upgrade to Rails 8. `config.cache_store`: The before and after `config.cache_store` settings are both just different eras of Rails default config. I don't think we're invested in the old default, so I'm accepting the new suggestion. `config.active_record.query_log_tags_enabled`: Enabling SQL query log tags in development doesn't sound very risky. `config.public_file_server.enabled`: Rails's public file server used to be off by default but that was apparently switched to on by default in a recent Rails version. The environment variable `RAILS_SERVE_STATIC_FILES` is something that Rails itself introduced and I haven't found any evidence to suggest that this app ever set the variable, so in practice the public file server was always off. I don't see any reason to change that now. --- config/environments/development.rb | 9 ++++----- config/environments/production.rb | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 524b5ed2d..158a78342 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -20,15 +20,14 @@ if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false - - config.cache_store = :null_store end + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -63,7 +62,7 @@ config.active_record.verbose_query_logs = true # Append comments with runtime information tags to SQL queries in logs. - # config.active_record.query_log_tags_enabled = true + config.active_record.query_log_tags_enabled = true # Highlight code that enqueued background job in logs. config.active_job.verbose_enqueue_logs = true diff --git a/config/environments/production.rb b/config/environments/production.rb index 4bd370f98..373e12230 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -15,8 +15,8 @@ # Turn on fragment caching in view templates. config.action_controller.perform_caching = true - # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + # Disable serving static files from `public/`. + config.public_file_server.enabled = false # Cache assets for far-future expiry since they are all digest stamped. # config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }