未验证 提交 3c58ec6d 编写于 作者: B bogdanvlviv 提交者: Kasper Timm Hansen

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.
上级 0097b24b
......@@ -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`.
......
......@@ -72,6 +72,7 @@ def initialize(*)
@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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册