About Resouce

 

关于RESTful风格的URL设计

 

Singular(单数)

 

resourceful route:

 

resource :geocoder

 

creates six different routes in your application, all mapping to the Geocoders controller:

VerbPathactionmethodused for
GET/geocoder/newnewnew_geocoder_pathreturn an HTML form for creating the geocoder
POST/geocodercreategeocoder_pathcreate the new geocoder
GET/geocodershowgeocoder_path(id)display the one and only geocoder resource
GET/geocoder/editeditedit_geocoder_path(id)return an HTML form for editing the geocoder
PUT/geocoderupdategeocoder_path(id)update the one and only geocoder resource
DELETE/geocoderdestroygeocoder_path(id)        delete the geocoder resource


Plural(复数)

resourceful route:

 

resources :photos

 

creates seven different routes in your application, all mapping to the Photos controller:

VerbPathactionmethodused for
GET/photosindexphotos_pathdisplay a list of all photos
GET/photos/newnewnew_photos_pathreturn an HTML form for creating a new photo
POST/photoscreatephotos_pathcreate a new photo
GET/photos/:idshowphoto_path(id)display a specific photo
GET/photos/:id/editeditedit_photo_path(id)return an HTML form for editing a photo
PUT/photos/:idupdatephoto_path(id)update a specific photo
DELETE/photos/:iddestroyphoto_path(id)        delete a specific photo

(continue)

---------------------------------------------------------------------------------------------------

参考

Rails Routing from the Outside In

http://guides.rubyonrails.org/routing.html#nested-names

 

Nesting resources

http://weblog.jamisbuck.org/2007/2/5/nesting-resources

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值