Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use consistent hash syntax for routes #35136

Merged
merged 1 commit into from
Feb 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions actionpack/lib/action_dispatch/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ module ActionDispatch
# For routes that don't fit the <tt>resources</tt> mold, you can use the HTTP helper
# methods <tt>get</tt>, <tt>post</tt>, <tt>patch</tt>, <tt>put</tt> and <tt>delete</tt>.
#
# get 'post/:id' => 'posts#show'
# post 'post/:id' => 'posts#create_comment'
# get 'post/:id', to: 'posts#show'
# post 'post/:id', to: 'posts#create_comment'
#
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
# URL will route to the <tt>show</tt> action.
#
# If your route needs to respond to more than one HTTP method (or all methods) then using the
# <tt>:via</tt> option on <tt>match</tt> is preferable.
#
# match 'post/:id' => 'posts#show', via: [:get, :post]
# match 'post/:id', to: 'posts#show', via: [:get, :post]
#
# == Named routes
#
Expand All @@ -94,7 +94,7 @@ module ActionDispatch
# Example:
#
# # In config/routes.rb
# get '/login' => 'accounts#login', as: 'login'
# get '/login', to: 'accounts#login', as: 'login'
#
# # With render, redirect_to, tests, etc.
# redirect_to login_url
Expand All @@ -120,9 +120,9 @@ module ActionDispatch
#
# # In config/routes.rb
# controller :blog do
# get 'blog/show' => :list
# get 'blog/delete' => :delete
# get 'blog/edit' => :edit
# get 'blog/show', to: :list
# get 'blog/delete', to: :delete
# get 'blog/edit', to: :edit
# end
#
# # provides named routes for show, delete, and edit
Expand All @@ -132,7 +132,7 @@ module ActionDispatch
#
# Routes can generate pretty URLs. For example:
#
# get '/articles/:year/:month/:day' => 'articles#find_by_id', constraints: {
# get '/articles/:year/:month/:day', to: 'articles#find_by_id', constraints: {
# year: /\d{4}/,
# month: /\d{1,2}/,
# day: /\d{1,2}/
Expand All @@ -147,7 +147,7 @@ module ActionDispatch
# You can specify a regular expression to define a format for a parameter.
#
# controller 'geocode' do
# get 'geocode/:postalcode' => :show, constraints: {
# get 'geocode/:postalcode', to: :show, constraints: {
# postalcode: /\d{5}(-\d{4})?/
# }
# end
Expand All @@ -156,13 +156,13 @@ module ActionDispatch
# expression modifiers:
#
# controller 'geocode' do
# get 'geocode/:postalcode' => :show, constraints: {
# get 'geocode/:postalcode', to: :show, constraints: {
# postalcode: /hx\d\d\s\d[a-z]{2}/i
# }
# end
#
# controller 'geocode' do
# get 'geocode/:postalcode' => :show, constraints: {
# get 'geocode/:postalcode', to: :show, constraints: {
# postalcode: /# Postalcode format
# \d{5} #Prefix
# (-\d{4})? #Suffix
Expand All @@ -178,21 +178,21 @@ module ActionDispatch
#
# You can redirect any path to another path using the redirect helper in your router:
#
# get "/stories" => redirect("/posts")
# get "/stories", to: redirect("/posts")
#
# == Unicode character routes
#
# You can specify unicode character routes in your router:
#
# get "こんにちは" => "welcome#index"
# get "こんにちは", to: "welcome#index"
#
# == Routing to Rack Applications
#
# Instead of a String, like <tt>posts#index</tt>, which corresponds to the
# index action in the PostsController, you can specify any Rack application
# as the endpoint for a matcher:
#
# get "/application.js" => Sprockets
# get "/application.js", to: Sprockets
#
# == Reloading routes
#
Expand Down
2 changes: 1 addition & 1 deletion guides/source/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ In each of these cases, the named routes remain the same as if you did not use `
| PATCH/PUT | /admin/articles/:id | articles#update | article_path(:id) |
| DELETE | /admin/articles/:id | articles#destroy | article_path(:id) |

TIP: _If you need to use a different controller namespace inside a `namespace` block you can specify an absolute controller path, e.g: `get '/foo' => '/foo#index'`._
TIP: _If you need to use a different controller namespace inside a `namespace` block you can specify an absolute controller path, e.g: `get '/foo', to: '/foo#index'`._

### Nested Resources

Expand Down