Reference: Chapter 4 (The Rails Way)
In Rails, by adding
Slowly but surely we are going to build an app from the ground up and use all of these RESTful routes. Its very important to understand what each of these do and how to incorporate them into your application. These routes control how we setup our controller, actions, links, and forms. It is amazing how much is conventionalized around one configuration line
In Rails, by adding
map.resources :stories
to config/routes.rb, you get 7 predefined routes:- stories GET /stories {:controller=>”stories”, :action=>”index”}
- POST /stories {:controller=>”stories”, :action=>”create”}
- new_story GET /stories/new {:controller=>”stories”, :action=>”new”}
- edit_story GET /stories/:id/edit {:controller=>”stories”, :action=>”edit”}
- story GET /stories/:id {:controller=>”stories”, :action=>”show”}
- PUT /stories/:id {:controller=>”stories”, :action=>”update”}
- DELETE /stories/:id {:controller=>”stories”, :action=>”destroy”}
Slowly but surely we are going to build an app from the ground up and use all of these RESTful routes. Its very important to understand what each of these do and how to incorporate them into your application. These routes control how we setup our controller, actions, links, and forms. It is amazing how much is conventionalized around one configuration line
map.resources :stories
- POST is a CREATE
- GET is a READ
- PUT is an UPDATE
- DELETE is a DELETE
Comments
Post a Comment