My app has Tickets, and a ticket can be "resolved". I can POST via AJAX to the :resolve action with no issues, but I cannot POST via a normal HTML form. I get No route matches "/tickets/321/resolve"
. Both the HTML form and the JS point to the same exact URL. What am I doing wrong?
Routes:
resources :tickets do
post :resolve, :on => :member
end
Controller:
def resolve
resource.resolved!
respond_to do |wants|
wants.html { redirect_to :back }
wants.js
end
end
Form:
= form_for(ticket, :url => resolve_ticket_path(ticke开发者_开发百科t)) do |f|
...
Actually when you are trying to send your form with exists resource (ticket) rails by default will send PUT
request, so you should set :method => :post
clear or change route from
post :resolve, :on => :member
to
put :resolve, :on => :member
精彩评论