我的应用有门票,门票可以“解决”。我可以通过AJAX发布到:解决操作没有问题,但我无法通过普通的HTML表单进行POST。我得到No route matches "/tickets/321/resolve"
。 HTML表单和JS都指向相同的URL。我做错了什么?
路线:
resources :tickets do
post :resolve, :on => :member
end
控制器:
def resolve
resource.resolved!
respond_to do |wants|
wants.html { redirect_to :back }
wants.js
end
end
形式:
= form_for(ticket, :url => resolve_ticket_path(ticket)) do |f|
...
答案 0 :(得分:1)
实际上,当您尝试发送包含现有资源(票证)的表单时,默认情况下会发送PUT
请求,因此您应该设置:method => :post
清除或更改路由
post :resolve, :on => :member
到
put :resolve, :on => :member