Sending a DELETE request from Sinatra Sending a DELETE request from Sinatra ruby ruby

Sending a DELETE request from Sinatra


Put following line in your code.

use Rack::MethodOverride

It will help you interpret post methods with parameter "_method" with value "delete" as put. Then you can write

delete '/user/:id' do |id|


I thinks it's like the Rails way. You need define a params '_method' with 'delete' value and add it on your form.

When you POST you form with this particular params, you do a DELETE request in sinatra.

Like :

<form action="/search" method="post">  <div style="margin:0;padding:0">    <input name="_method" type="hidden" value="delete" />  </div></form>

It's the same with PUT method


Another way is to use Curl:

curl -X DELETE http://host/user/1