4

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 2

8

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.

1
  • I put enable :method_override in my Sinatra::Base subclass and it works great. :)
    – user142019
    Commented Nov 28, 2011 at 15:46
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.