In the rails version upgrade process, when you execute the rails app: update
command, a file called config/initializers/new_framework_defaults_6_1.rb
will be created.
This file contains the settings to keep the application settings compatible between rails 6.0 and 6.1.
When actually upgrading the version, it is necessary to understand the contents because the version is upgraded while checking the setting values of this file, so each item will be explained in a few lines. Details on how to use it will not be written in this article. config/initializers/new_framework_defaults_6_1.rwo
Rails.application.config.active_record.has_many_inversing = true
There was a bug fix that the callback of the association model was executed when creating the association model when inverse_of: was added with has_many, but since it is a destructive change, it is now turned off in the option setting ..
The default is false
, and the callback will still be executed.
See: https://github.com/rails/rails/pull/37413 https://github.com/rails/rails/pull/37429
Rails.application.config.active_storage.track_variants = true
Since the overhead of checking the existence of variants in ActiveStorage is large, the process is abolished by default, and if you want to check the existence, you can set it as an option.
See: https://github.com/rails/rails/pull/37901
Rails.application.config.active_job.retry_jitter = 0.15
Jitter is now specified by default. If you want to change the default value, rewrite the value.
See: https://github.com/rails/rails/pull/37923
Rails.application.config.active_job.skip_after_callbacks_if_terminated = true
In ActibJob, if the callback chain is halted when the job is executed, after_enqueue and after_perform are not executed. This is a destructive change and is set to false by default for compatibility. (Callback is executed even if = halt) Specify true if you want to enable the new behavior.
Rails.application.config.action_dispatch.cookies_same_site_protection = :lax
The value of the SameSite attribute is now specified when writing a cookie.
The default is Lax.
If you want to make it Strict, specify : strict
. If you want to disable SameSite, specify : none
.
If you enable this setting, it will be incompatible with previous versions. Since rollback becomes difficult, it is recommended to set it to : none
and specify this again after the version upgrade is stable.
Rails.application.config.action_controller.urlsafe_csrf_tokens = true The CSRF encoding has changed from base64 to urlsafe base64.
If you enable this setting, it will be incompatible with previous versions. Since rollback becomes difficult, it is recommended to set it to false
, delete the setting after the version upgrade is stable, and move to the default behavior true
.
ActiveSupport.utc_to_local_returns_utc_offset_times = true
By upgrading gem'tzinfo' to v2, the return value of ActiveSupport :: TimeZone.utc_to_local
now includes UTC offset.
The default is false
and the return value does not include UTC offset.
Rails.application.config.action_dispatch.ssl_default_redirect_status = 308
Defines the default HTTP status code used when redirecting GET, HEAD requests from HTTP to HTTPS to 308, which conforms to RFC7538.
See: https://tools.ietf.org/html/rfc7538
Rails.application.config.active_record.legacy_connection_handling = false
You can now call the connected_to
method not only from ActiveRecord :: Base
, but also from abstract classes.
Switch collections to make multiple database connections within the abstract class.
Rails.application.config.action_view.form_with_generates_remote_forms = false
The data-remote
attribute of the form
tag generated by the form_with
helper now defaults from false
to true
. Set false
to be compatible with lower versions.
Rails.application.config.active_storage.queues.analysis = nil
config.active_storage.queue
has been deprecated and split into config.active_storage.queues.analysis
and config.active_storage.queues.purge
.
When an object is registered in the DB with ActiveStorage, metadata is extracted from the file via ActiveJob and saved in the metadata column of the blob record. (This column is often used to extract height and width from an image using mini_magick.) This job's queue could only be queued to the default queue, but now you can specify a queue with this option.
Rails.application.config.active_storage.queues.purge = nil
config.active_storage.queue
has been deprecated and split into config.active_storage.queues.analysis
and config.active_storage.queues.purge
.
The job queue that deletes old files when updating the file path pointed to by an ActiveStorage object could only be queued to the default queue, but this option can now be used to specify a queue.
Rails.application.config.action_mailbox.queues.incineration = nil The execution queue of incinerate (delete) ActiveJob of successfully processed Inbound Email is now selectable.
Rails.application.config.action_mailbox.queues.routing = nil The execution queue of ActiveJob that performs routing processing when receiving Inbound Email can now be selected. It's asynchronous because it accepts new incoming mail without taking the time to hang while doing other processing.
Rails.application.config.action_mailer.deliver_later_queue_name = nil The execution queue of ActiveJob that sends mail asynchronously with ActionMailer can now be selected.
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 6.1 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Support for inversing belongs_to -> has_many Active Record associations.
# Rails.application.config.active_record.has_many_inversing = true
# Track Active Storage variants in the database.
# Rails.application.config.active_storage.track_variants = true
# Apply random variation to the delay when retrying failed jobs.
# Rails.application.config.active_job.retry_jitter = 0.15
# Stop executing `after_enqueue`/`after_perform` callbacks if
# `before_enqueue`/`before_perform` respectively halts with `throw :abort`.
# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true
# Specify cookies SameSite protection level: either :none, :lax, or :strict.
#
# This change is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 6.1.
# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax
# Generate CSRF tokens that are encoded in URL-safe Base64.
#
# This change is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 6.1.
# Rails.application.config.action_controller.urlsafe_csrf_tokens = true
# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an
# UTC offset or a UTC time.
# ActiveSupport.utc_to_local_returns_utc_offset_times = true
# Change the default HTTP status code to `308` when redirecting non-GET/HEAD
# requests to HTTPS in `ActionDispatch::SSL` middleware.
# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308
# Use new connection handling API. For most applications this won't have any
# effect. For applications using multiple databases, this new API provides
# support for granular connection swapping.
# Rails.application.config.active_record.legacy_connection_handling = false
# Make `form_with` generate non-remote forms by default.
# Rails.application.config.action_view.form_with_generates_remote_forms = false
# Set the default queue name for the analysis job to the queue adapter default.
# Rails.application.config.active_storage.queues.analysis = nil
# Set the default queue name for the purge job to the queue adapter default.
# Rails.application.config.active_storage.queues.purge = nil
# Set the default queue name for the incineration job to the queue adapter default.
# Rails.application.config.action_mailbox.queues.incineration = nil
# Set the default queue name for the routing job to the queue adapter default.
# Rails.application.config.action_mailbox.queues.routing = nil
# Set the default queue name for the mail deliver job to the queue adapter default.
# Rails.application.config.action_mailer.deliver_later_queue_name = nil
https://guides.rubyonrails.org/configuring.html
Recommended Posts