diff options
author | Andrew White <andrew.white@unboxed.co> | 2018-03-12 13:41:12 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2018-03-12 13:42:08 +0000 |
commit | 6fdc379c194db56e80747480bdd17ef5c3dcfc13 (patch) | |
tree | d3b2e029ded497624df2f4d06b972dff5dc9cb04 /guides | |
parent | 76d516089691cf448604a368af8a8279b5b1f28f (diff) | |
download | rails-6fdc379c194db56e80747480bdd17ef5c3dcfc13.tar.gz rails-6fdc379c194db56e80747480bdd17ef5c3dcfc13.tar.bz2 rails-6fdc379c194db56e80747480bdd17ef5c3dcfc13.zip |
Add section to routing guide about config/routes.rb [ci skip]
Closes #32219.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/routing.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/guides/source/routing.md b/guides/source/routing.md index 98aa841938..971fd548f9 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -58,6 +58,26 @@ and this in the corresponding view: then the router will generate the path `/patients/17`. This reduces the brittleness of your view and makes your code easier to understand. Note that the id does not need to be specified in the route helper. +### Configuring the Rails Router + +The routes for your application or engine live in the file `config/routes.rb` and typically looks like this: + +```ruby +Rails.application.routes.draw do + resources :brands, only: [:index, :show] + resources :products, only: [:index, :show] + end + + resource :basket, only: [:show, :update, :destroy] + + resolve("Basket") { route_for(:basket) } +end +``` + +Since this is a regular Ruby source file you can use all of its features to help you define your routes but be careful with variable names as they can clash with the DSL methods of the router. + +NOTE: The `Rails.application.routes.draw do ... end` block that wraps your route definitions is required to establish the scope for the router DSL and must not be deleted. + Resource Routing: the Rails Default ----------------------------------- |