Rails Route

1.The purpose of the rails router

The rails router recognizes URLS and dispatch them to a controller's action. It's still generate URLs and paths to controller's action,avoid to hardcode.

2.Resource route:the rails default

.One resource route will create seven routes,e.g:

resources :photos

HTTP Verb Path action used for
GET /photos index display a list of all photos
GET /photos/new new return an HTML form for creating a new photo
POST /photos create create a new photo
GET /photos/:id show display a specific photo
GET /photos/:id/edit edit return an HTML form for editing a photo
PUT /photos/:id update update a specific photo
DELETE /photos/:id destroy delete a specific photo


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章