Skip to content

Commit

Permalink
Update some more config following Rails 8 upgrade
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mike3985 committed Jan 21, 2025
1 parent 81efb36 commit b2800ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
Expand Down

0 comments on commit b2800ca

Please sign in to comment.