Tag: delete method

为什么使用HTTP PUT和DELETE方法而不是POST?

new_story GET /story/new(.:format) {:action=>”new”, :controller=>”stories”} edit_story GET /story/edit(.:format) {:action=>”edit”, :controller=>”stories”} story GET /story(.:format) {:action=>”show”, :controller=>”stories”} PUT /story(.:format) {:action=>”update”, :controller=>”stories”} DELETE /story(.:format) {:action=>”destroy”, :controller=>”stories”} POST /story(.:format) {:action=>”create”, :controller=>”stories”} 在网络工作中,我已经完成了其他技术,我只使用过GET和POST方法。 但是在Rails中使用RESTful路由时,默认情况下,PUT和DELETE方法用于更新和销毁操作。 使用PUT和DELETE的优点或需求是什么? 我假设这些方法只是做POST的另一种方式 – 但为什么不坚持使用POST?

Rails删除方法它不起作用

好吧,我在Ruby on Rails中遇到删除方法存在这样的问题,我想,我尝试了所有我读过的但是它不起作用也许你gusy可以帮助修复差距。 当我点击链接它重定向到患者/ 1?确认=是+你+确定%3F&方法=删除 但是从我的chrome控制台收到一条消息Uncaught SyntaxError:Unexpected token =:3000 / assets / application.js?body = 1:13属于 =需要jquery 我的代码如下: patients.controller def show @patient = Patient.find(params[:id]) end def new @patient = Patient.new @patients = Patient.find(:all) end def create @patient = Patient.new(params[:patient]) if @patient.save redirect_to new_patient_path end end def edit @patient = Patient.find(params[:id]) end def update @patient = Patient.find(params[:id]) […]