diff options
author | Zachary Scott <e@zzak.io> | 2014-09-26 19:53:10 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-09-26 19:53:10 -0700 |
commit | 7c4a623c257bd52b72be5400984f45ee42b40f0d (patch) | |
tree | a60c8526ac93d04de8cadf8654a9d98b548d660c /guides | |
parent | 4581d044776604ea82b5696251419b5b63727333 (diff) | |
parent | 89b8836f2470c689f6b7d52cab3a418bb63aef26 (diff) | |
download | rails-7c4a623c257bd52b72be5400984f45ee42b40f0d.tar.gz rails-7c4a623c257bd52b72be5400984f45ee42b40f0d.tar.bz2 rails-7c4a623c257bd52b72be5400984f45ee42b40f0d.zip |
Merge pull request #17076 from yuki24/write-doc-for-rescue-responses
Add documentation about rescue_responses in Configuring [ci skip]
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/configuring.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 06c279c18f..7b9710bcd8 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -364,6 +364,29 @@ encrypted cookies salt value. Defaults to `'signed encrypted cookie'`. 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, + 'ActionDispatch::ParamsParser::ParseError' => :bad_request, + 'ActionController::BadRequest' => :bad_request, + 'ActionController::ParameterMissing' => :bad_request, + 'ActiveRecord::RecordNotFound' => :not_found, + 'ActiveRecord::StaleObjectError' => :conflict, + 'ActiveRecord::RecordInvalid' => :unprocessable_entity, + 'ActiveRecord::RecordNotSaved' => :unprocessable_entity + } + ``` + + Any execptions that are not configured will be assigned to 500 Internal server error. + * `ActionDispatch::Callbacks.before` takes a block of code to run before the request. * `ActionDispatch::Callbacks.to_prepare` takes a block to run after `ActionDispatch::Callbacks.before`, but before the request. Runs for every request in `development` mode, but only once for `production` or environments with `cache_classes` set to `true`. |