Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 582
nonopolarity Avatar asked Oct 12 '22 13:10

nonopolarity


1 Answers

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.

like image 128
sarnold Avatar answered Nov 07 '22 11:11

sarnold