[Proposal] Routing: allow symbol HTTP statuses in `redirect_to`


I propose augmenting ActionDispatch::Routing::Redirection#redirect so it can accept a symbolic status:

get '/everyone', to: redirect('/users', status: :found)

in addition to the current numeric HTTP status:

get '/everyone', to: redirect('/users', status: 302)


ActionController::Redirecting#redirect_to accepts a status option, which takes an HTTP code as a number or a symbol. For example:

redirect_to(other_url, status: 204)
# or, equivalently:
redirect_to(other_url, status: :no_content)

The same isn’t true of ActionDispatch::Routing::Redirection#redirect. I would love to add symbol support to the latter for consistency.

1 Like

Should have checked out the latest — looks like someone merged a PR that enables this on August 10!