0

因此,我将编辑功能添加到我的支付控制器,如下所示:

 def edit

   @payment = Payment.edit
     if @payment.save
       redirect_to showCompany_path, notice: 'Successfully edited!'
     else
       render :edit
     end
   end

我的付款/视图中有一个相应的 edit.html.haml 视图。这是我的路线 rb:

resources :companies do
   put :edit, :on => :collection

   resources :payments do
     put :edit, :on => :collection
   end
end

我想在我的另一个视图中有一个指向此付款编辑的链接,我这样定义:

<%= link_to 'Edit Payment Info', edit_company_payment_path(company), {:style=>'color:black; display:inline;', :class=>"btn btn-primary" }  %>

我想我已经做了我应该做的一切,但我仍然从标题中得到这个错误。请帮忙。


为了生成指向company/:company_id/payments/:payment_id 的url,Rails 还需要知道付款。换句话说,您缺少付款参数:

edit_company_payment_path(company, payment)
4

2 回答 2

0

根据您的错误, :company_id 是一个对象而不是整数。尝试这个,

edit_company_payment_path({:company_id => company.id, :payment_id => @payment.id})
于 2013-10-26T06:17:59.790 回答
0

In order to generate a url to companies/:company_id/payments/:payment_id, Rails needs to know th e payment as well. In other words, you are missing the payment param:

edit_company_payment_path(company, payment)
于 2013-10-25T19:17:53.433 回答