-
-
Save petrblaho/2965271 to your computer and use it in GitHub Desktop.
Rails routing for nested resources with :as parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| api_post_comments GET /api/posts/:post_id/comments(.:format) comments#index | |
| POST /api/posts/:post_id/comments(.:format) comments#create | |
| new_api_post_comment GET /api/posts/:post_id/comments/new(.:format) comments#new | |
| edit_api_post_comment GET /api/posts/:post_id/comments/:id/edit(.:format) comments#edit | |
| api_post_comment GET /api/posts/:post_id/comments/:id(.:format) comments#show | |
| PUT /api/posts/:post_id/comments/:id(.:format) comments#update | |
| DELETE /api/posts/:post_id/comments/:id(.:format) comments#destroy | |
| api_posts GET /api/posts(.:format) posts#index | |
| POST /api/posts(.:format) posts#create | |
| new_api_post GET /api/posts/new(.:format) posts#new | |
| edit_api_post GET /api/posts/:id/edit(.:format) posts#edit | |
| api_post GET /api/posts/:id(.:format) posts#show | |
| PUT /api/posts/:id(.:format) posts#update | |
| DELETE /api/posts/:id(.:format) posts#destroy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| api_post_comments GET /api/posts/:api_post_id/comments(.:format) comments#index | |
| POST /api/posts/:api_post_id/comments(.:format) comments#create | |
| new_api_post_comment GET /api/posts/:api_post_id/comments/new(.:format) comments#new | |
| edit_api_post_comment GET /api/posts/:api_post_id/comments/:id/edit(.:format) comments#edit | |
| api_post_comment GET /api/posts/:api_post_id/comments/:id(.:format) comments#show | |
| PUT /api/posts/:api_post_id/comments/:id(.:format) comments#update | |
| DELETE /api/posts/:api_post_id/comments/:id(.:format) comments#destroy | |
| api_posts GET /api/posts(.:format) posts#index | |
| POST /api/posts(.:format) posts#create | |
| new_api_post GET /api/posts/new(.:format) posts#new | |
| edit_api_post GET /api/posts/:id/edit(.:format) posts#edit | |
| api_post GET /api/posts/:id(.:format) posts#show | |
| PUT /api/posts/:id(.:format) posts#update | |
| DELETE /api/posts/:id(.:format) posts#destroy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Blog::Application.routes.draw do | |
| # 1st variant | |
| scope "/api", :as => 'api' do | |
| resources :posts do | |
| resources :comments | |
| end | |
| end | |
| # 2nd variant | |
| scope "/api" do | |
| resources :posts, :as => 'api_posts' do | |
| resources :comments | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment