I am using <%= form_for @invoice, url: {action: :pay} do |f| %>
but the form is sent to the update action instead of the "pay" action I defined in the controller. What am I missing?
You have param :id
in your route, and you should assign a param to id
in your form action, try this
<%= form_for @invoice, url: {action: "pay", params: {id: @invoice.id}} %>
Or you can use a path
<%= form_for @invoice, url: for_pay_path(@invoice) %>
for_pay_path
change to path of pay
action, you can see on ouput of rake routes