diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 1154b0491cd..d8d6eff8e77 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1025,4 +1025,2315 @@ The previous behavior was to validate the presence of the parent record, which p to get the parent every time the child record was updated, even when parent has not changed. | Starting with version | The default value is | -| --------------------- | --\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x2D\x20\x7C\x0A\x7C\x20\x28\x6F\x72\x69\x67\x69\x6E\x61\x6C\x29\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7C\x20\x60\x74\x72\x75\x65\x60\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7C\x0A\x7C\x20\x37\x2E\x31\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7C\x20\x60\x66\x61\x6C\x73\x65\x60\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x7C\x0A\x0A\x23\x23\x23\x23\x20\x60\x63\x6F\x6E\x66\x69\x67\x2E\x61\x63\x74\x69\x76\x65\x5F\x72\x65\x63\x6F\x72\x64\x2E\x61\x63\x74\x69\x6F\x6E\x5F\x6F\x6E\x5F\x73\x74\x72\x69\x63\x74\x5F\x6C\x6F\x61\x64\x69\x6E\x67\x5F\x76\x69\x6F\x6C\x61\x74\x69\x6F\x6E\x60\x0A\x0A\x45\x6E\x61\x62\x6C\x65\x73\x20\x72\x61\x69\x73\x69\x6E\x67\x20\x6F\x72\x20\x6C\x6F\x67\x67\x69\x6E\x67\x20\x61\x6E\x20\x65\x78\x63\x65\x70\x74\x69\x6F\x6E\x20\x69\x66\x20\x73\x74\x72\x69\x63\x74\x5F\x6C\x6F\x61\x64\x69\x6E\x67\x20\x69\x73\x20\x73\x65\x74\x20\x6F\x6E\x20\x61\x6E\x0A\x61\x73\x73\x6F\x63\x69\x61\x74\x69\x6F\x6E\x2E\x20\x54\x68\x65\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x76\x61\x6C\x75\x65\x20\x69\x73\x20\x60\x3A\x72\x61\x69\x73\x65\x60\x20\x69\x6E\x20\x61\x6C\x6C\x20\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74\x73\x2E\x20\x49\x74\x20\x63\x61\x6E\x20\x62\x65\x0A\x63\x68\x61\x6E\x67\x65\x64\x20\x74\x6F\x20\x60\x3A\x6C\x6F\x67\x60\x20\x74\x6F\x20\x73\x65\x6E\x64\x20\x76\x69\x6F\x6C\x61\x74\x69\x6F\x6E\x73\x20\x74\x6F\x20\x74\x68\x65\x20\x6C\x6F\x67\x67\x65\x72\x20\x69\x6E\x73\x74\x65\x61\x64\x20\x6F\x66\x20\x72\x61\x69\x73\x69\x6E\x67\x2E\x0A\x0A\x23\x23\x23\x23\x20\x60\x63\x6F\x6E\x66\x69\x67\x2E\x61\x63\x74\x69\x76\x65\x5F\x72\x65\x63\x6F\x72\x64\x2E\x73\x74\x72\x69\x63\x74\x5F\x6C\x6F\x61\x64\x69\x6E\x67\x5F\x62\x79\x5F\x64\x65\x66\x61\x75\x6C\x74\x60\x0A\x0A\x49\x73\x20\x61\x20\x62\x6F\x6F\x6C\x65\x61\x6E\x20\x76\x61\x6C\x75\x65\x20\x74\x68\x61\x74\x20\x65\x69\x74\x68\x65\x72\x20\x65\x6E\x61\x62\x6C\x65\x73\x20\x6F\x72\x20\x64\x69\x73\x61\x62\x6C\x65\x73\x20\x73\x74\x72\x69\x63\x74\x5F\x6C\x6F\x61\x64\x69\x6E\x67\x20\x6D\x6F\x64\x65\x20\x62\x79\x0A\x64\x65\x66\x61\x75\x6C\x74\x2E\x20\x44\x65\x66\x61\x75\x6C\x74\x73\x20\x74\x6F\x20\x60\x66\x61\x6C\x73\x65\x60\x2E\x0A\x0A\x23\x23\x23\x23\x20\x60\x63\x6F\x6E\x66\x69\x67\x2E\x61\x63\x74\x69\x76\x65\x5F\x72\x65\x63\x6F\x72\x64\x2E\x77\x61\x72\x6E\x5F\x6F\x6E\x5F\x72\x65\x63\x6F\x72\x64\x73\x5F\x66\x65\x74\x63\x68\x65\x64\x5F\x67\x72\x65\x61\x74\x65\x72\x5F\x74\x68\x61\x6E\x60\x0A\x0A\x41\x6C\x6C\x6F\x77\x73\x20\x73\x65\x74\x74\x69\x6E\x67\x20\x61\x20\x77\x61\x72\x6E\x69\x6E\x67\x20\x74\x68\x72\x65\x73\x68\x6F\x6C\x64\x20\x66\x6F\x72\x20\x71\x75\x65\x72\x79\x20\x72\x65\x73\x75\x6C\x74\x20\x73\x69\x7A\x65\x2E\x20\x49\x66\x20\x74\x68\x65\x20\x6E\x75\x6D\x62\x65\x72\x20\x6F\x66\x0A\x72\x65\x63\x6F\x72\x64\x73\x20\x72\x65\x74\x75\x72\x6E\x65\x64\x20\x62\x79\x20\x61\x20\x71\x75\x65\x72\x79\x20\x65\x78\x63\x65\x65\x64\x73\x20\x74\x68\x65\x20\x74\x68\x72\x65\x73\x68\x6F\x6C\x64\x2C\x20\x61\x20\x77\x61\x72\x6E\x69\x6E\x67\x20\x69\x73\x20\x6C\x6F\x67\x67\x65\x64\x2E\x20\x54\x68\x69\x73\x0A\x63\x61\x6E\x20\x62\x65\x20\x75\x73\x65\x64\x20\x74\x6F\x20\x69\x64\x65\x6E\x74\x69\x66\x79\x20\x71\x75\x65\x72\x69\x65\x73\x20\x77\x68\x69\x63\x68\x20\x6D\x69\x67\x68\x74\x20\x62\x65\x20\x63\x61\x75\x73\x69\x6E\x67\x20\x61\x20\x6D\x65\x6D\x6F\x72\x79\x20\x62\x6C\x6F\x61\x74\x2E\x0A\x0A\x23\x23\x23\x23\x20\x60\x63\x6F\x6E\x66\x69\x67\x2E\x61\x63\x74\x69\x76\x65\x5F\x72\x65\x63\x6F\x72\x64\x2E\x69\x6E\x64\x65\x78\x5F\x6E\x65\x73\x74\x65\x64\x5F\x61\x74\x74\x72\x69\x62\x75\x74\x65\x5F\x65\x72\x72\x6F\x72\x73\x60\x0A\x0A\x41\x6C\x6C\x6F\x77\x73\x20\x65\x72\x72\x6F\x72\x73\x20\x66\x6F\x72\x20\x6E\x65\x73\x74\x65\x64\x20\x60\x68\x61\x73\x5F\x6D\x61\x6E\x79\x60\x20\x72\x65\x6C\x61\x74\x69\x6F\x6E\x73\x68\x69\x70\x73\x20\x74\x6F\x20\x62\x65\x20\x64\x69\x73\x70\x6C\x61\x79\x65\x64\x20\x77\x69\x74\x68\x20\x61\x6E\x20\x69\x6E\x64\x65\x78\x0A\x61\x73\x20\x77\x65\x6C\x6C\x20\x61\x73\x20\x74\x68\x65\x20\x65\x72\x72\x6F\x72\x2E\x20\x44\x65\x66\x61\x75\x6C\x74\x73\x20\x74\x6F\x2 \ No newline at end of file +| --------------------- | -------------------- | +| (original) | `true` | +| 7.1 | `false` | + +#### `config.active_record.action_on_strict_loading_violation` + +Enables raising or logging an exception if strict_loading is set on an +association. The default value is `:raise` in all environments. It can be +changed to `:log` to send violations to the logger instead of raising. + +#### `config.active_record.strict_loading_by_default` + +Is a boolean value that either enables or disables strict_loading mode by +default. Defaults to `false`. + +#### `config.active_record.warn_on_records_fetched_greater_than` + +Allows setting a warning threshold for query result size. If the number of +records returned by a query exceeds the threshold, a warning is logged. This +can be used to identify queries which might be causing a memory bloat. + +#### `config.active_record.index_nested_attribute_errors` + +Allows errors for nested `has_many` relationships to be displayed with an index +as well as the error. Defaults to `false`. + +#### `config.active_record.use_schema_cache_dump` + +Enables users to get schema cache information from `db/schema_cache.yml` +(generated by `bin/rails db:schema:cache:dump`), instead of having to send a +query to the database to get this information. Defaults to `true`. + +#### `config.active_record.cache_versioning` + +Indicates whether to use a stable `#cache_key` method that is accompanied by a +changing version in the `#cache_version` method. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 5.2 | `true` | + +#### `config.active_record.collection_cache_versioning` + +Enables the same cache key to be reused when the object being cached of type +`ActiveRecord::Relation` changes by moving the volatile information (max +updated at and count) of the relation's cache key into the cache version to +support recycling cache key. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 6.0 | `true` | + +#### `config.active_record.has_many_inversing` + +Enables setting the inverse record when traversing `belongs_to` to `has_many` +associations. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 6.1 | `true` | + +#### `config.active_record.automatic_scope_inversing` + +Enables automatically inferring the `inverse_of` for associations with a scope. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 7.0 | `true` | + +#### `config.active_record.destroy_association_async_job` + +Allows specifying the job that will be used to destroy the associated records in background. It defaults to `ActiveRecord::DestroyAssociationAsyncJob`. + +#### `config.active_record.destroy_association_async_batch_size` + +Allows specifying the maximum number of records that will be destroyed in a background job by the `dependent: :destroy_async` association option. All else equal, a lower batch size will enqueue more, shorter-running background jobs, while a higher batch size will enqueue fewer, longer-running background jobs. This option defaults to `nil`, which will cause all dependent records for a given association to be destroyed in the same background job. + +#### `config.active_record.queues.destroy` + +Allows specifying the Active Job queue to use for destroy jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `nil`. + +#### `config.active_record.enumerate_columns_in_select_statements` + +When `true`, will always include column names in `SELECT` statements, and avoid wildcard `SELECT * FROM ...` queries. This avoids prepared statement cache errors when adding columns to a PostgreSQL database for example. Defaults to `false`. + +#### `config.active_record.verify_foreign_keys_for_fixtures` + +Ensures all foreign key constraints are valid after fixtures are loaded in tests. Supported by PostgreSQL and SQLite only. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 7.0 | `true` | + +#### `config.active_record.raise_on_assign_to_attr_readonly` + +Enable raising on assignment to attr_readonly attributes. The previous +behavior would allow assignment but silently not persist changes to the +database. + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 7.1 | `true` | + +#### `config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction` + +When multiple Active Record instances change the same record within a transaction, Rails runs `after_commit` or `after_rollback` callbacks for only one of them. This option specifies how Rails chooses which instance receives the callbacks. + +When `true`, transactional callbacks are run on the first instance to save, even though its instance state may be stale. + +When `false`, transactional callbacks are run on the instances with the freshest instance state. Those instances are chosen as follows: + +- In general, run transactional callbacks on the last instance to save a given record within the transaction. +- There are two exceptions: + - If the record is created within the transaction, then updated by another instance, `after_create_commit` callbacks will be run on the second instance. This is instead of the `after_update_commit` callbacks that would naively be run based on that instance’s state. + - If the record is destroyed within the transaction, then `after_destroy_commit` callbacks will be fired on the last destroyed instance, even if a stale instance subsequently performed an update (which will have affected 0 rows). + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `true` | +| 7.1 | `false` | + +#### `config.active_record.query_log_tags_enabled` + +Specifies whether or not to enable adapter-level query comments. Defaults to +`false`. + +#### `config.active_record.query_log_tags` + +Define an `Array` specifying the key/value tags to be inserted in an SQL +comment. Defaults to `[ :application ]`, a predefined tag returning the +application name. + +#### `config.active_record.query_log_tags_format` + +A `Symbol` specifying the formatter to use for tags. Valid values are `:sqlcommenter` and `:legacy`. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `:legacy` | +| 7.1 | `:sqlcommenter` | + +#### `config.active_record.cache_query_log_tags` + +Specifies whether or not to enable caching of query log tags. For applications +that have a large number of queries, caching query log tags can provide a +performance benefit when the context does not change during the lifetime of the +request or job execution. Defaults to `false`. + +#### `config.active_record.schema_cache_ignored_tables` + +Define the list of table that should be ignored when generating the schema +cache. It accepts an `Array` of strings, representing the table names, or +regular expressions. + +#### `config.active_record.verbose_query_logs` + +Specifies if source locations of methods that call database queries should be logged below relevant queries. By default, the flag is `true` in development and `false` in all other environments. + +#### `config.active_record.sqlite3_adapter_strict_strings_by_default` + +Specifies whether the SQLite3Adapter should be used in a strict strings mode. +The use of a strict strings mode disables double-quoted string literals. + +SQLite has some quirks around double-quoted string literals. +It first tries to consider double-quoted strings as identifier names, but if they don't exist +it then considers them as string literals. Because of this, typos can silently go unnoticed. +For example, it is possible to create an index for a non existing column. +See [SQLite documentation](https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted) for more details. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 7.1 | `true` | + +#### `config.active_record.async_query_executor` + +Specifies how asynchronous queries are pooled. + +It defaults to `nil`, which means `load_async` is disabled and instead directly executes queries in the foreground. +For queries to actually be performed asynchronously, it must be set to either `:global_thread_pool` or `:multi_thread_pool`. + +`:global_thread_pool` will use a single pool for all databases the application connects to. This is the preferred configuration +for applications with only a single database, or applications which only ever query one database shard at a time. + +`:multi_thread_pool` will use one pool per database, and each pool size can be configured individually in `database.yml` through the +`max_threads` and `min_thread` properties. This can be useful to applications regularly querying multiple databases at a time, and that need to more precisely define the max concurrency. + +#### `config.active_record.global_executor_concurrency` + +Used in conjunction with `config.active_record.async_query_executor = :global_thread_pool`, defines how many asynchronous +queries can be executed concurrently. + +Defaults to `4`. + +This number must be considered in accordance with the database pool size configured in `database.yml`. The connection pool +should be large enough to accommodate both the foreground threads (.e.g web server or job worker threads) and background threads. + +#### `config.active_record.allow_deprecated_singular_associations_name` + +This enables deprecated behavior wherein singular associations can be referred to by their plural name in `where` clauses. Setting this to `false` is more performant. + +```ruby +class Comment < ActiveRecord::Base + belongs_to :post +end + +Comment.where(post: post_id).count # => 5 + +# When `allow_deprecated_singular_associations_name` is true: +Comment.where(posts: post_id).count # => 5 (deprecation warning) + +# When `allow_deprecated_singular_associations_name` is false: +Comment.where(posts: post_id).count # => error +``` + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `true` | +| 7.1 | `false` | + +#### `config.active_record.yaml_column_permitted_classes` + +Defaults to `[Symbol]`. Allows applications to include additional permitted classes to `safe_load()` on the `ActiveRecord::Coders::YAMLColumn`. + +#### `config.active_record.use_yaml_unsafe_load` + +Defaults to `false`. Allows applications to opt into using `unsafe_load` on the `ActiveRecord::Coders::YAMLColumn`. + +#### `ActiveRecord::ConnectionAdapters::Mysql2Adapter.emulate_booleans` + +Controls whether the Active Record MySQL adapter will consider all `tinyint(1)` columns as booleans. Defaults to `true`. + +#### `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables` + +Controls whether database tables created by PostgreSQL should be "unlogged", which can speed +up performance but adds a risk of data loss if the database crashes. It is +highly recommended that you do not enable this in a production environment. +Defaults to `false` in all environments. + +#### `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.datetime_type` + +Controls what native type the Active Record PostgreSQL adapter should use when you call `datetime` in +a migration or schema. It takes a symbol which must correspond to one of the +configured `NATIVE_DATABASE_TYPES`. The default is `:timestamp`, meaning +`t.datetime` in a migration will create a "timestamp without time zone" column. +To use "timestamp with time zone", change this to `:timestamptz` in an +initializer. You should run `bin/rails db:migrate` to rebuild your schema.rb +if you change this. + +#### `ActiveRecord::SchemaDumper.ignore_tables` + +Accepts an array of tables that should _not_ be included in any generated schema file. + +#### `ActiveRecord::SchemaDumper.fk_ignore_pattern` + +Allows setting a different regular expression that will be used to decide +whether a foreign key's name should be dumped to db/schema.rb or not. By +default, foreign key names starting with `fk_rails_` are not exported to the +database schema dump. Defaults to `/^fk_rails_[0-9a-f]{10}$/`. + +### Configuring Action Controller + +`config.action_controller` includes a number of configuration settings: + +#### `config.action_controller.asset_host` + +Sets the host for the assets. Useful when CDNs are used for hosting assets rather than the application server itself. You should only use this if you have a different configuration for Action Mailer, otherwise use `config.asset_host`. + +#### `config.action_controller.perform_caching` + +Configures whether the application should perform the caching features provided by the Action Controller component or not. Set to `false` in the development environment, `true` in production. If it's not specified, the default will be `true`. + +#### `config.action_controller.default_static_extension` + +Configures the extension used for cached pages. Defaults to `.html`. + +#### `config.action_controller.include_all_helpers` + +Configures whether all view helpers are available everywhere or are scoped to the corresponding controller. If set to `false`, `UsersHelper` methods are only available for views rendered as part of `UsersController`. If `true`, `UsersHelper` methods are available everywhere. The default configuration behavior (when this option is not explicitly set to `true` or `false`) is that all view helpers are available to each controller. + +#### `config.action_controller.logger` + +Accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Action Controller. Set to `nil` to disable logging. + +#### `config.action_controller.request_forgery_protection_token` + +Sets the token parameter name for RequestForgery. Calling `protect_from_forgery` sets it to `:authenticity_token` by default. + +#### `config.action_controller.allow_forgery_protection` + +Enables or disables CSRF protection. By default this is `false` in the test environment and `true` in all other environments. + +#### `config.action_controller.forgery_protection_origin_check` + +Configures whether the HTTP `Origin` header should be checked against the site's origin as an additional CSRF defense. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 5.0 | `true` | + +#### `config.action_controller.per_form_csrf_tokens` + +Configures whether CSRF tokens are only valid for the method/action they were generated for. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 5.0 | `true` | + +#### `config.action_controller.default_protect_from_forgery` + +Determines whether forgery protection is added on `ActionController::Base`. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 5.2 | `true` | + +#### `config.action_controller.relative_url_root` + +Can be used to tell Rails that you are [deploying to a subdirectory]( +configuring.html#deploy-to-a-subdirectory-relative-url-root). The default is +[`config.relative_url_root`](#config-relative-url-root). + +#### `config.action_controller.permit_all_parameters` + +Sets all the parameters for mass assignment to be permitted by default. The default value is `false`. + +#### `config.action_controller.action_on_unpermitted_parameters` + +Controls behavior when parameters that are not explicitly permitted are found. The default value is `:log` in test and development environments, `false` otherwise. The values can be: + +* `false` to take no action +* `:log` to emit an `ActiveSupport::Notifications.instrument` event on the `unpermitted_parameters.action_controller` topic and log at the DEBUG level +* `:raise` to raise a `ActionController::UnpermittedParameters` exception + +#### `config.action_controller.always_permitted_parameters` + +Sets a list of permitted parameters that are permitted by default. The default values are `['controller', 'action']`. + +#### `config.action_controller.enable_fragment_cache_logging` + +Determines whether to log fragment cache reads and writes in verbose format as follows: + +``` +Read fragment views/v1/2914079/v1/2914079/recordings/70182313-20160225015037000000/d0bdf2974e1ef6d31685c3b392ad0b74 (0.6ms) +Rendered messages/_message.html.erb in 1.2 ms [cache hit] +Write fragment views/v1/2914079/v1/2914079/recordings/70182313-20160225015037000000/3b4e249ac9d168c617e32e84b99218b5 (1.1ms) +Rendered recordings/threads/_thread.html.erb in 1.5 ms [cache miss] +``` + +By default it is set to `false` which results in following output: + +``` +Rendered messages/_message.html.erb in 1.2 ms [cache hit] +Rendered recordings/threads/_thread.html.erb in 1.5 ms [cache miss] +``` + +#### `config.action_controller.raise_on_open_redirects` + +Raises an `ActionController::Redirecting::UnsafeRedirectError` when an unpermitted open redirect occurs. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 7.0 | `true` | + +#### `config.action_controller.log_query_tags_around_actions` + +Determines whether controller context for query tags will be automatically +updated via an `around_filter`. The default value is `true`. + +#### `config.action_controller.wrap_parameters_by_default` + +Configures the [`ParamsWrapper`](https://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html) to wrap json +request by default. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 7.0 | `true` | + +#### `ActionController::Base.wrap_parameters` + +Configures the [`ParamsWrapper`](https://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html). This can be called at +the top level, or on individual controllers. + +#### `config.action_controller.allow_deprecated_parameters_hash_equality` + +Controls behavior of `ActionController::Parameters#==` with `Hash` arguments. +Value of the setting determines whether an `ActionController::Parameters` instance is equal to an equivalent `Hash`. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `true` | +| 7.1 | `false` | + +### Configuring Action Dispatch + +#### `config.action_dispatch.cookies_serializer` + +Specifies which serializer to use for cookies. For more information, see [Action Controller Cookies](action_controller_overview.html#cookies). + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `:marshal` | +| 7.0 | `:json` | + +#### `config.action_dispatch.default_headers` + +Is a hash with HTTP headers that are set by default in each response. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) |
{
"X-Frame-Options" => "SAMEORIGIN",
"X-XSS-Protection" => "1; mode=block",
"X-Content-Type-Options" => "nosniff",
"X-Download-Options" => "noopen",
"X-Permitted-Cross-Domain-Policies" => "none",
"Referrer-Policy" => "strict-origin-when-cross-origin"
}
| +| 7.0 |
{
"X-Frame-Options" => "SAMEORIGIN",
"X-XSS-Protection" => "0",
"X-Content-Type-Options" => "nosniff",
"X-Download-Options" => "noopen",
"X-Permitted-Cross-Domain-Policies" => "none",
"Referrer-Policy" => "strict-origin-when-cross-origin"
}
| +| 7.1 |
{
"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"
}
| + +#### `config.action_dispatch.default_charset` + +Specifies the default character set for all renders. Defaults to `nil`. + +#### `config.action_dispatch.tld_length` + +Sets the TLD (top-level domain) length for the application. Defaults to `1`. + +#### `config.action_dispatch.ignore_accept_header` + +Is used to determine whether to ignore accept headers from a request. Defaults to `false`. + +#### `config.action_dispatch.x_sendfile_header` + +Specifies server specific X-Sendfile header. This is useful for accelerated file sending from server. For example it can be set to 'X-Sendfile' for Apache. + +#### `config.action_dispatch.http_auth_salt` + +Sets the HTTP Auth salt value. Defaults +to `'http authentication'`. + +#### `config.action_dispatch.signed_cookie_salt` + +Sets the signed cookies salt value. +Defaults to `'signed cookie'`. + +#### `config.action_dispatch.encrypted_cookie_salt` + +Sets the encrypted cookies salt value. Defaults to `'encrypted cookie'`. + +#### `config.action_dispatch.encrypted_signed_cookie_salt` + +Sets the signed encrypted cookies salt value. Defaults to `'signed encrypted +cookie'`. + +#### `config.action_dispatch.authenticated_encrypted_cookie_salt` + +Sets the authenticated encrypted cookie salt. Defaults to `'authenticated +encrypted cookie'`. + +#### `config.action_dispatch.encrypted_cookie_cipher` + +Sets the cipher to be used for encrypted cookies. This defaults to +`"aes-256-gcm"`. + +#### `config.action_dispatch.signed_cookie_digest` + +Sets the digest to be used for signed cookies. This defaults to `"SHA1"`. + +#### `config.action_dispatch.cookies_rotations` + +Allows rotating secrets, ciphers, and digests for encrypted and signed cookies. + +#### `config.action_dispatch.use_authenticated_cookie_encryption` + +Controls whether signed and encrypted cookies use the AES-256-GCM cipher or the +older AES-256-CBC cipher. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 5.2 | `true` | + +#### `config.action_dispatch.use_cookies_with_metadata` + +Enables writing cookies with the purpose metadata embedded. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 6.0 | `true` | + +#### `config.action_dispatch.perform_deep_munge` + +Configures whether `deep_munge` method should be performed on the parameters. +See [Security Guide](security.html#unsafe-query-generation) for more +information. It defaults to `true`. + +#### `config.action_dispatch.rescue_responses` + +Configures what exceptions are assigned to an HTTP status. It accepts a hash and you can specify pairs of exception/status. By default, this is defined as: + +```ruby +config.action_dispatch.rescue_responses = { + 'ActionController::RoutingError' + => :not_found, + 'AbstractController::ActionNotFound' + => :not_found, + 'ActionController::MethodNotAllowed' + => :method_not_allowed, + 'ActionController::UnknownHttpMethod' + => :method_not_allowed, + 'ActionController::NotImplemented' + => :not_implemented, + 'ActionController::UnknownFormat' + => :not_acceptable, + 'ActionController::InvalidAuthenticityToken' + => :unprocessable_entity, + 'ActionController::InvalidCrossOriginRequest' + => :unprocessable_entity, + 'ActionDispatch::Http::Parameters::ParseError' + => :bad_request, + 'ActionController::BadRequest' + => :bad_request, + 'ActionController::ParameterMissing' + => :bad_request, + 'Rack::QueryParser::ParameterTypeError' + => :bad_request, + 'Rack::QueryParser::InvalidParameterError' + => :bad_request, + 'ActiveRecord::RecordNotFound' + => :not_found, + 'ActiveRecord::StaleObjectError' + => :conflict, + 'ActiveRecord::RecordInvalid' + => :unprocessable_entity, + 'ActiveRecord::RecordNotSaved' + => :unprocessable_entity +} +``` + +Any exceptions that are not configured will be mapped to 500 Internal Server Error. + +#### `config.action_dispatch.return_only_request_media_type_on_content_type` + +Change the return value of `ActionDispatch::Request#content_type` to the +Content-Type header without modification. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `true` | +| 7.0 | `false` | + +#### `config.action_dispatch.cookies_same_site_protection` + +Configures the default value of the `SameSite` attribute when setting cookies. +When set to `nil`, the `SameSite` attribute is not added. To allow the value of +the `SameSite` attribute to be configured dynamically based on the request, a +proc may be specified. For example: + +```ruby +config.action_dispatch.cookies_same_site_protection = ->(request) do + :strict unless request.user_agent == "TestAgent" +end +``` + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `nil` | +| 6.1 | `:lax` | + +#### `config.action_dispatch.ssl_default_redirect_status` + +Configures the default HTTP status code used when redirecting non-GET/HEAD +requests from HTTP to HTTPS in the `ActionDispatch::SSL` middleware. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `307` | +| 6.1 | `308` | + +#### `config.action_dispatch.log_rescued_responses` + +Enables logging those unhandled exceptions configured in `rescue_responses`. It +defaults to `true`. + +#### `ActionDispatch::Callbacks.before` + +Takes a block of code to run before the request. + +#### `ActionDispatch::Callbacks.after` + +Takes a block of code to run after the request. + +### Configuring Action View + +`config.action_view` includes a small number of configuration settings: + +#### `config.action_view.cache_template_loading` + +Controls whether or not templates should be reloaded on each request. Defaults to `!config.enable_reloading`. + +#### `config.action_view.field_error_proc` + +Provides an HTML generator for displaying errors that come from Active Model. The block is evaluated within +the context of an Action View template. The default is + +```ruby +Proc.new { |html_tag, instance| content_tag :div, html_tag, class: "field_with_errors" } +``` + +#### `config.action_view.default_form_builder` + +Tells Rails which form builder to use by default. The default is +`ActionView::Helpers::FormBuilder`. If you want your form builder class to be +loaded after initialization (so it's reloaded on each request in development), +you can pass it as a `String`. + +#### `config.action_view.logger` + +Accepts a logger conforming to the interface of Log4r or the default Ruby Logger class, which is then used to log information from Action View. Set to `nil` to disable logging. + +#### `config.action_view.erb_trim_mode` + +Gives the trim mode to be used by ERB. It defaults to `'-'`, which turns on trimming of tail spaces and newline when using `<%= -%>` or `<%= =%>`. See the [Erubis documentation](http://www.kuwata-lab.com/erubis/users-guide.06.html#topics-trimspaces) for more information. + +#### `config.action_view.frozen_string_literal` + +Compiles the ERB template with the `# frozen_string_literal: true` magic comment, making all string literals frozen and saving allocations. Set to `true` to enable it for all views. + +#### `config.action_view.embed_authenticity_token_in_remote_forms` + +Allows you to set the default behavior for `authenticity_token` in forms with +`remote: true`. By default it's set to `false`, which means that remote forms +will not include `authenticity_token`, which is helpful when you're +fragment-caching the form. Remote forms get the authenticity from the `meta` +tag, so embedding is unnecessary unless you support browsers without +JavaScript. In such case you can either pass `authenticity_token: true` as a +form option or set this config setting to `true`. + +#### `config.action_view.prefix_partial_path_with_controller_namespace` + +Determines whether or not partials are looked up from a subdirectory in templates rendered from namespaced controllers. For example, consider a controller named `Admin::ArticlesController` which renders this template: + +```erb +<%= render @article %> +``` + +The default setting is `true`, which uses the partial at `/admin/articles/_article.erb`. Setting the value to `false` would render `/articles/_article.erb`, which is the same behavior as rendering from a non-namespaced controller such as `ArticlesController`. + +#### `config.action_view.automatically_disable_submit_tag` + +Determines whether `submit_tag` should automatically disable on click, this +defaults to `true`. + +#### `config.action_view.debug_missing_translation` + +Determines whether to wrap the missing translations key in a `` tag or not. This defaults to `true`. + +#### `config.action_view.form_with_generates_remote_forms` + +Determines whether `form_with` generates remote forms or not. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| 5.1 | `true` | +| 6.1 | `false` | + +#### `config.action_view.form_with_generates_ids` + +Determines whether `form_with` generates ids on inputs. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `false` | +| 5.2 | `true` | + +#### `config.action_view.default_enforce_utf8` + +Determines whether forms are generated with a hidden tag that forces older versions of Internet Explorer to submit forms encoded in UTF-8. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `true` | +| 6.0 | `false` | + +#### `config.action_view.image_loading` + +Specifies a default value for the `loading` attribute of `` tags rendered by the `image_tag` helper. For example, when set to `"lazy"`, `` tags rendered by `image_tag` will include `loading="lazy"`, which [instructs the browser to wait until an image is near the viewport to load it](https://html.spec.whatwg.org/#lazy-loading-attributes). (This value can still be overridden per image by passing e.g. `loading: "eager"` to `image_tag`.) Defaults to `nil`. + +#### `config.action_view.image_decoding` + +Specifies a default value for the `decoding` attribute of `` tags rendered by the `image_tag` helper. Defaults to `nil`. + +#### `config.action_view.annotate_rendered_view_with_filenames` + +Determines whether to annotate rendered view with template file names. This defaults to `false`. + +#### `config.action_view.preload_links_header` + +Determines whether `javascript_include_tag` and `stylesheet_link_tag` will generate a `Link` header that preload assets. + +The default value depends on the `config.load_defaults` target version: + +| Starting with version | The default value is | +| --------------------- | -------------------- | +| (original) | `nil` | +| 6.1 | `true` | + +#### `config.action_view.button_to_generates_button_tag` + +Determines whether `button_to` will render `