aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/configuring.md
diff options
context:
space:
mode:
authorYuki Nishijima <mail@yukinishijima.net>2014-09-26 19:45:05 -0700
committerYuki Nishijima <mail@yukinishijima.net>2014-09-26 19:45:05 -0700
commit89b8836f2470c689f6b7d52cab3a418bb63aef26 (patch)
treea60c8526ac93d04de8cadf8654a9d98b548d660c /guides/source/configuring.md
parent4581d044776604ea82b5696251419b5b63727333 (diff)
downloadrails-89b8836f2470c689f6b7d52cab3a418bb63aef26.tar.gz
rails-89b8836f2470c689f6b7d52cab3a418bb63aef26.tar.bz2
rails-89b8836f2470c689f6b7d52cab3a418bb63aef26.zip
Add documentation about `config.action_dispatch.rescue_responses`
[ci skip]
Diffstat (limited to 'guides/source/configuring.md')
-rw-r--r--guides/source/configuring.md23
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`.