Rails Route

来源:互联网 发布:网络诈骗代办信用卡 编辑:程序博客网 时间:2024/06/06 09:27

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 VerbPathactionused forGET/photosindexdisplay a list of all photosGET/photos/newnewreturn an HTML form for creating a new photoPOST/photoscreatecreate a new photoGET/photos/:idshowdisplay a specific photoGET/photos/:id/editeditreturn an HTML form for editing a photoPUT/photos/:idupdateupdate a specific photoDELETE/photos/:iddestroydelete a specific photo


原创粉丝点击