?
关于RESTful风格的URL设计
?
Singular(单数)
?
resourceful route:
?
resource :geocoder
?
creates six different routes in your application, all mapping to the Geocoders controller:
Verb
Path
action
method
used for
GET
/geocoder/new
new
new_geocoder_path
return an?HTML?form for creating the geocoder
POST
/geocoder
create
geocoder_path
create the new geocoder
GET
/geocoder
show
geocoder_path(id)
display the one and only geocoder resource
GET
/geocoder/edit
edit
edit_geocoder_path(id)
return an?HTML?form for editing the geocoder
PUT
/geocoder
update
geocoder_path(id)
update the one and only geocoder resource
DELETE
/geocoder
destroy
geocoder_path(id) ? ? ? ?
delete the geocoder resource
Plural(复数)
resourceful route:
?
resources :photos
?
creates seven different routes in your application, all mapping to the Photos controller:
Verb
Path
action
method
used for
GET
/photos
index
photos_path
display a list of all photos
GET
/photos/new
new
new_photos_path
return an?HTML?form for creating a new photo
POST
/photos
create
photos_path
create a new photo
GET
/photos/:id
show
photo_path(id)
display a specific photo
GET
/photos/:id/edit
edit
edit_photo_path(id)
return an?HTML?form for editing a photo
PUT
/photos/:id
update
photo_path(id)
update a specific photo
DELETE
/photos/:id
destroy
photo_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