diff options
Diffstat (limited to 'railties/doc/guides/source/routing_outside_in.txt')
-rw-r--r-- | railties/doc/guides/source/routing_outside_in.txt | 113 |
1 files changed, 54 insertions, 59 deletions
diff --git a/railties/doc/guides/source/routing_outside_in.txt b/railties/doc/guides/source/routing_outside_in.txt index 3f6c80de5c..235832e4f3 100644 --- a/railties/doc/guides/source/routing_outside_in.txt +++ b/railties/doc/guides/source/routing_outside_in.txt @@ -132,18 +132,17 @@ map.resources :photos creates seven different routes in your application: -[grid="all"] -`----------`---------------`-----------`--------`------------------------------------------- -HTTP verb URL controller action used for --------------------------------------------------------------------------------------------- -GET /photos Photos index display a list of all photos -GET /photos/new Photos new return an HTML form for creating a new photo -POST /photos Photos create create a new photo -GET /photos/1 Photos show display a specific photo -GET /photos/1/edit Photos edit return an HTML form for editing a photo -PUT /photos/1 Photos update update a specific photo -DELETE /photos/1 Photos destroy delete a specific photo --------------------------------------------------------------------------------------------- +[options="header"] +|========================================================================================================== +|HTTP verb |URL |controller |action |used for +|GET |/photos |Photos |index |display a list of all photos +|GET |/photos/new |Photos |new |return an HTML form for creating a new photo +|POST |/photos |Photos |create |create a new photo +|GET |/photos/1 |Photos |show |display a specific photo +|GET |/photos/1/edit |Photos |edit |return an HTML form for editing a photo +|PUT |/photos/1 |Photos |update |update a specific photo +|DELETE |/photos/1 |Photos |destroy |delete a specific photo +|========================================================================================================== For the specific routes (those that reference just a single resource), the identifier for the resource will be available within the corresponding controller action as +params[:id]+. @@ -197,17 +196,16 @@ map.resource :geocoder creates six different routes in your application: -[grid="all"] -`----------`---------------`-----------`--------`------------------------------------------- -HTTP verb URL controller action used for --------------------------------------------------------------------------------------------- -GET /geocoder/new Geocoders new return an HTML form for creating the new geocoder -POST /geocoder Geocoders create create the new geocoder -GET /geocoder Geocoders show display the one and only geocoder resource -GET /geocoder/edit Geocoders edit return an HTML form for editing the geocoder -PUT /geocoder Geocoders update update the one and only geocoder resource -DELETE /geocoder Geocoders destroy delete the geocoder resource --------------------------------------------------------------------------------------------- +[options="header"] +|========================================================================================================== +|HTTP verb |URL |controller |action |used for +|GET |/geocoder/new |Geocoders |new |return an HTML form for creating the new geocoder +|POST |/geocoder |Geocoders |create |create the new geocoder +|GET |/geocoder |Geocoders |show |display the one and only geocoder resource +|GET |/geocoder/edit |Geocoders |edit |return an HTML form for editing the geocoder +|PUT |/geocoder |Geocoders |update |update the one and only geocoder resource +|DELETE |/geocoder |Geocoders |destroy |delete the geocoder resource +|========================================================================================================== NOTE: Even though the name of the resource is singular in +routes.rb+, the matching controller is still plural. @@ -245,18 +243,17 @@ map.resources :photos, :controller => "images" will recognize incoming URLs containing +photo+ but route the requests to the Images controller: -[grid="all"] -`----------`---------------`-----------`--------`------------------------------------------- -HTTP verb URL controller action used for --------------------------------------------------------------------------------------------- -GET /photos Images index display a list of all images -GET /photos/new Images new return an HTML form for creating a new image -POST /photos Images create create a new image -GET /photos/1 Images show display a specific image -GET /photos/1/edit Images edit return an HTML form for editing a image -PUT /photos/1 Images update update a specific image -DELETE /photos/1 Images destroy delete a specific image --------------------------------------------------------------------------------------------- +[options="header"] +|========================================================================================================== +|HTTP verb |URL |controller |action |used for +|GET |/photos |Images |index |display a list of all images +|GET |/photos/new |Images |new |return an HTML form for creating a new image +|POST |/photos |Images |create |create a new image +|GET |/photos/1 |Images |show |display a specific image +|GET |/photos/1/edit |Images |edit |return an HTML form for editing a image +|PUT |/photos/1 |Images |update |update a specific image +|DELETE |/photos/1 |Images |destroy |delete a specific image +|========================================================================================================== NOTE: The helpers will be generated with the name of the resource, not the name of the controller. So in this case, you'd still get +photos_path+, +new_photo_path+, and so on. @@ -328,18 +325,17 @@ map.resources :photos, :as => "images" will recognize incoming URLs containing +image+ but route the requests to the Photos controller: -[grid="all"] -`----------`---------------`-----------`--------`------------------------------------------- -HTTP verb URL controller action used for --------------------------------------------------------------------------------------------- -GET /images Photos index display a list of all photos -GET /images/new Photos new return an HTML form for creating a new photo -POST /images Photos create create a new photo -GET /images/1 Photos show display a specific photo -GET /images/1/edit Photos edit return an HTML form for editing a photo -PUT /images/1 Photos update update a specific photo -DELETE /images/1 Photos destroy delete a specific photo --------------------------------------------------------------------------------------------- +[options="header"] +|========================================================================================================== +|HTTP verb |URL |controller |action |used for +|GET |/images |Photos |index |display a list of all photos +|GET |/images/new |Photos |new |return an HTML form for creating a new photo +|POST |/images |Photos |create |create a new photo +|GET |/images/1 |Photos |show |display a specific photo +|GET |/images/1/edit |Photos |edit |return an HTML form for editing a photo +|PUT |/images/1 |Photos |update |update a specific photo +|DELETE |/images/1 |Photos |destroy |delete a specific photo +|========================================================================================================== NOTE: The helpers will be generated with the name of the resource, not the path name. So in this case, you'd still get +photos_path+, +new_photo_path+, and so on. @@ -452,18 +448,17 @@ end In addition to the routes for magazines, this declaration will also create routes for ads, each of which requires the specification of a magazine in the URL: -[grid="all"] -`----------`-----------------------`-----------`--------`------------------------------------------- -HTTP verb URL controller action used for --------------------------------------------------------------------------------------------- -GET /magazines/1/ads Ads index display a list of all ads for a specific magazine -GET /magazines/1/ads/new Ads new return an HTML form for creating a new ad belonging to a specific magazine -POST /magazines/1/ads Ads create create a new ad belonging to a specific magazine -GET /magazines/1/ads/1 Ads show display a specific ad belonging to a specific magazine -GET /magazines/1/ads/1/edit Ads edit return an HTML form for editing an ad belonging to a specific magazine -PUT /magazines/1/ads/1 Ads update update a specific ad belonging to a specific magazine -DELETE /magazines/1/ads/1 Ads destroy delete a specific ad belonging to a specific magazine --------------------------------------------------------------------------------------------- +[options="header"] +|========================================================================================================== +|HTTP verb |URL |controller |action |used for +|GET |/magazines/1/ads |Ads |index |display a list of all ads for a specific magazine +|GET |/magazines/1/ads/new |Ads |new |return an HTML form for creating a new ad belonging to a specific magazine +|POST |/magazines/1/ads |Ads |create |create a new ad belonging to a specific magazine +|GET |/magazines/1/ads/1 |Ads |show |display a specific ad belonging to a specific magazine +|GET |/magazines/1/ads/1/edit |Ads |edit |return an HTML form for editing an ad belonging to a specific magazine +|PUT |/magazines/1/ads/1 |Ads |update |update a specific ad belonging to a specific magazine +|DELETE |/magazines/1/ads/1 |Ads |destroy |delete a specific ad belonging to a specific magazine +|========================================================================================================== This will also create routing helpers such as +magazine_ads_url+ and +edit_magazine_ad_path+. |