Why Ruby on Rails books or references always say Update is by PUT and Destroy is by DELETE when it is not?
Because if I use Fiddler to monitor it, it is:
CRUD Method Path With Idempotent? action
---- ------ ---- ---- ----------- ------
Create POST /foos/ No create
Retrieve GET /foos/:id Yes show
Update POST /foos/:id _method=put Yes update
Destroy POST /foos/:id _method=delete Yes destroy开发者_运维问答
so PUT
and DELETE
(as HTTP verb) are not actually used. But why do Rails books and references always say it is PUT
and DELETE
?
Because web browsers have no interface to generate PUT
or DELETE
requests.
Of course, clients that you program have enough flexibility to use PUT
and DELETE
as intended, but browsers can really only use GET
and POST
.
Because they SHOULD be PUT and DELETE but many servers out of the box do not support PUT and DELETE, so they tunnel it through POST.
精彩评论