How do you send a request with the “DELETE” HTTP verb?

后端 未结 4 1197
温柔的废话
温柔的废话 2020-12-29 00:09

I\'d like to create a link in a view within a Rails application that does this...

DELETE /sessions

How would I do that.

Added compl

4条回答
  •  滥情空心
    2020-12-29 00:40

    Correct, browsers don't actually support sending delete requests. The accepted convention of many web frameworks is to send a _method parameter set to 'DELETE', and use a POST request.

    Here's an example in Rails:

    <%= link_to 'log out', session_path, :method => :delete %>
    

    You may want to have a look at Restful Authentication.

提交回复
热议问题