How to add custom routes to resource route

Add this in your routes:

resources :invoices do
  post :send, on: :member
end

Or

resources :invoices do
  member do
    post :send
  end
end

Then in your views:

<%= button_to "Send Invoice", send_invoice_path(@invoice) %>

Or

<%= link_to "Send Invoice", send_invoice_path(@invoice), method: :post %>

Of course, you are not tied to the POST method

Leave a Comment