我目前在发票控制器中有一个create方法。但是我需要另一个,称为“ create_inappointment_invoice”。我想知道在routes文件中创建与此相关的路由的语法是什么。我基本上想要与此resources :invoices, controller: "admins/invoices", only: [:create]
相同的路由,但是要更改控制器动作的名称。谢谢
答案 0 :(得分:2)
post 'admins/all_invoices', to: 'admin#invoices'
其中admin是您的控制者,并在其中执行操作。
答案 1 :(得分:0)
类似下面的代码片段应该可以完成这项工作:
resources :invoices, controller: "admins/invoices", only: [:create] do
collection do
post :create_inappointment_invoice
end
end
OR
resources :invoices, controller: "admins/invoices", only: [:create] do
post :create_inappointment_invoice, on: :collection
end
这将在您的create_inappointment_invoice
中使用admin/invoices controller
方法
答案 2 :(得分:0)
这似乎可行:
`post "/invoices", to: "admins/invoices#create_inappointment_invoice", as: :create_inappointment_invoice`