Skip to content

Commit

Permalink
Enable almost all Rails 7.1 framework defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
veganstraightedge committed Feb 27, 2024
1 parent 2164f4e commit 4c04b81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 11 additions & 9 deletions config/initializers/new_framework_defaults_7_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4c04b81

Please sign in to comment.