From 4c04b813218b327dc96e8e46f798557639f98520 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 26 Feb 2024 20:45:01 -0800 Subject: [PATCH] Enable almost all Rails 7.1 framework defaults --- config/application.rb | 1 + .../new_framework_defaults_7_1.rb | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/config/application.rb b/config/application.rb index 5586acc64..b3d774646 100644 --- a/config/application.rb +++ b/config/application.rb @@ -29,6 +29,7 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.0 + config.active_support.cache_format_version = 7.1 # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb index fcb4d2e83..127d87e2c 100644 --- a/config/initializers/new_framework_defaults_7_1.rb +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -23,13 +23,14 @@ # Remove the default X-Download-Options headers since it is used only by Internet Explorer. # If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. #++ -Rails.application.config.action_dispatch.default_headers = { - 'X-Frame-Options' => 'SAMEORIGIN', - 'X-XSS-Protection' => '0', - 'X-Content-Type-Options' => 'nosniff', - 'X-Permitted-Cross-Domain-Policies' => 'none', - 'Referrer-Policy' => 'strict-origin-when-cross-origin' -} +# TODO: enable this one by itself, after the rest +# Rails.application.config.action_dispatch.default_headers = { +# 'X-Frame-Options' => 'SAMEORIGIN', +# 'X-XSS-Protection' => '0', +# 'X-Content-Type-Options' => 'nosniff', +# 'X-Permitted-Cross-Domain-Policies' => 'none', +# 'Referrer-Policy' => 'strict-origin-when-cross-origin' +# } ### # Do not treat an `ActionController::Parameters` instance @@ -138,7 +139,7 @@ # servers, first deploy without changing the serializer, then set the serializer # in a subsequent deploy. #++ -Rails.application.config.active_support.message_serializer = :json_allow_marshal +Rails.application.config.active_support.message_serializer = ActiveSupport::JSON ### # Enable a performance optimization that serializes message data and metadata @@ -173,7 +174,8 @@ # The previous behavior was to validate the presence of the parent record, which performed an extra query # to get the parent every time the child record was updated, even when parent has not changed. #++ -Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false +# TODO: enable this one by itself, after the rest +# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false ### # Enable precompilation of `config.filter_parameters`. Precompilation can