Some web browsers can't make PUT or DELETE requests, but I need to make those to my REST service written in Ruby using Sinatra. Is it possible to make Sinatra interpret a POST request as a PUT or DELETE request?
2 Answers
Please read the document and find the description of method_override
. The mechanism is identical as Rails. If your browser doesn't support PUT
& DELETE
, just send a extra parameter named _method
with value PUT
or DELETE
.
Notice that in Modular application (your class inherits Sinatra::Base
), method_override
is disabled by default. You need to enable it manually.
-
I put
enable :method_override
in mySinatra::Base
subclass and it works great. :)– user142019Commented Nov 28, 2011 at 15:46
All current web browsers support PUT and DELETE in XMLHttpRequest. Also, as far as I know, no browser supports them in HTML forms, mainly because it hasn't been specified yet what they'd do precisely.