Merge pull request #44133 from Shopify/strip-load-path-by-default

Disable config.add_autoload_paths_to_load_path by default in Rails 7.1
This commit is contained in:
Jean Boussier 2022-01-11 12:12:08 +01:00 committed by GitHub
commit b6987d6e14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -78,6 +78,14 @@ To allow you to upgrade to new defaults one by one, the update task has created
Upgrading from Rails 7.0 to Rails 7.1
-------------------------------------
### Autoloaded paths are no longer in load path
Starting from Rails 7.1, all paths managed by the autoloader will no longer be added to `$LOAD_PATH`.
This means it won't be possible to load them with a manual `require` call, the class or module can be referenced instead.
Reducing the size of `$LOAD_PATH` speed-up `require` calls for apps not using `bootsnap`, and reduce the
size of the `bootsnap` cache for the others.
Upgrading from Rails 6.1 to Rails 7.0
-------------------------------------

View File

@ -1,3 +1,12 @@
* No longer add autoloaded paths to `$LOAD_PATH`.
This means it won't be possible to load them with a manual `require` call, the class or module can be referenced instead.
Reducing the size of `$LOAD_PATH` speed-up `require` calls for apps not using `bootsnap`, and reduce the
size of the `bootsnap` cache for the others.
*Jean Boussier*
* Remove default `X-Download-Options` header
This header is currently only used by Internet Explorer which

View File

@ -261,6 +261,8 @@ module Rails
when "7.1"
load_defaults "7.0"
self.add_autoload_paths_to_load_path = false
if respond_to?(:action_dispatch)
action_dispatch.default_headers = {
"X-Frame-Options" => "SAMEORIGIN",

View File

@ -9,6 +9,12 @@
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able
# to manually require files that are managed by the autoloader, which you shouldn't do anyway.
# This reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size
# of the bootsnap cache if you use it.
# Rails.application.config.add_autoload_paths_to_load_path = false
# 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 = {