From 3c58ec6db99dc410f4db631d2e337d61903fa410 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Wed, 30 Oct 2019 14:14:36 +0000 Subject: [PATCH] Improve docs of the `load_defaults` method [ci skip] I changed `load_defaults` to `config.load_defaults` in the guide to emphasize its context, sorted headers "With 'x.x'" in descending and rephrased them to "With 'x.x', it includes previous versions' new defaults" and documented the method on https://api.rubyonrails.org. --- guides/source/configuring.md | 48 ++++++++++--------- .../lib/rails/application/configuration.rb | 1 + 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 33ca952080..3111e9c5d6 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -889,31 +889,11 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla * `config.active_storage.draw_routes` can be used to toggle Active Storage route generation. The default is `true`. -### Results of `load_defaults` +### Results of `config.load_defaults` -#### With '5.0': +`config.load_defaults` sets new defaults up to and including the version passed. Such that passing, say, '6.0' also gets the new defaults from every version before it. -- `config.action_controller.per_form_csrf_tokens`: `true` -- `config.action_controller.forgery_protection_origin_check`: `true` -- `ActiveSupport.to_time_preserves_timezone`: `true` -- `config.active_record.belongs_to_required_by_default`: `true` -- `config.ssl_options`: `{ hsts: { subdomains: true } }` - -#### With '5.1': - -- `config.assets.unknown_asset_fallback`: `false` -- `config.action_view.form_with_generates_remote_forms`: `true` - -#### With '5.2': - -- `config.active_record.cache_versioning`: `true` -- `config.action_dispatch.use_authenticated_cookie_encryption`: `true` -- `config.active_support.use_authenticated_message_encryption`: `true` -- `config.active_support.use_sha1_digests`: `true` -- `config.action_controller.default_protect_from_forgery`: `true` -- `config.action_view.form_with_generates_ids`: `true` - -#### With '6.0': +#### For '6.0', new defaults from previous versions below and: - `config.autoloader`: `:zeitwerk` - `config.action_view.default_enforce_utf8`: `false` @@ -926,6 +906,28 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla - `config.active_storage.replace_on_assign_to_many`: `true` - `config.active_record.collection_cache_versioning`: `true` +#### For '5.2', new defaults from previous versions below and: + +- `config.active_record.cache_versioning`: `true` +- `config.action_dispatch.use_authenticated_cookie_encryption`: `true` +- `config.active_support.use_authenticated_message_encryption`: `true` +- `config.active_support.use_sha1_digests`: `true` +- `config.action_controller.default_protect_from_forgery`: `true` +- `config.action_view.form_with_generates_ids`: `true` + +#### For '5.1', new defaults from previous versions below and: + +- `config.assets.unknown_asset_fallback`: `false` +- `config.action_view.form_with_generates_remote_forms`: `true` + +#### For '5.0': + +- `config.action_controller.per_form_csrf_tokens`: `true` +- `config.action_controller.forgery_protection_origin_check`: `true` +- `ActiveSupport.to_time_preserves_timezone`: `true` +- `config.active_record.belongs_to_required_by_default`: `true` +- `config.ssl_options`: `{ hsts: { subdomains: true } }` + ### Configuring a Database Just about every Rails application will interact with a database. You can connect to the database by setting an environment variable `ENV['DATABASE_URL']` or by using a configuration file called `config/database.yml`. diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 93d3c430b5..3585d26b80 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -72,6 +72,7 @@ module Rails @feature_policy = nil end + # Loads default configurations. See {the result of the method for each version}[https://guides.rubyonrails.org/configuring.html#results-of-config-load-defaults]. def load_defaults(target_version) case target_version.to_s when "5.0"