1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Disable config.add_autoload_paths_to_load_path by default in Rails 7.1

Ref: 668673f779

Now that Zeitwerk is the only autoloader, there no reason
to add autoloaded paths to `$LOAD_PATH`.
This commit is contained in:
Jean Boussier 2022-01-10 11:00:07 +01:00
parent c79ad9d227
commit a191321f7b
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 = {