说我有一个名为invoice的对象。在routes.rb
我有
resources :invoices do
get "pay"
end
当我运行rake routes
时,路由生成为
invoice_pay GET /invoices/:invoice_id/pay(.:format) invoices#pay
,参数为:invoices_id
,而不是:id
如果我使用匹配声明:
match "invoices/:id/pay" => "invoices#pay", :via => :get
我明白了:
GET /invoices/:id/pay(.:format) invoices#pay
在我看来,路线应该是pay_invoice_path(@invoice)
,但是,我还没有找到合适的文件。有什么建议吗?
答案 0 :(得分:1)
我认为你要做的是
resources :invoices do
get "pay", :on => :member
end