Ruby Net::HTTP 如何 删除资源

liker · July 05, 2013 · Last by liker replied at July 05, 2013 · 2237 hits

Net::HTTP 调用 RESTful 的 API 实现添加功能如下:

uri = URI.parse("http://166.111.138.220:3000/patients")
Net::HTTP.post_form(uri, {"patient[patient_name]" => params[:patient][:patient_name]})

如何实现删除一个用户的调用 例如:DELETE patients/19

Net::HTTP.post_form(uri, {"patient[patient_name]" => params[:patient][:patient_name], "_method" => ”delete"})

大概是这样

uri = URI.parse(http://166.111.138.220:3000/patients/19)
@response=Net::HTTP.post_form(uri, { '_method' => 'delete'})

已解决 3Q

You need to Sign in before reply, if you don't have an account, please Sign up first.