我試圖條紋添加到下面這個教程我的Rails應用程序,但無法弄清楚什麼地方出了錯:Rails的嵌套的資源不工作
Assigning Charges To Resources With Stripe Checkout
下面是我的代碼,
routes.rb中
resources :people, :path => "" do
member do
put :activate
put :deactivate
end
resources :listings do
member do
put :close
put :move_to_top
put :show_in_updates_email
end
resources :charges
end
和the.haml
= form_tag listings_charges_path(@listings) do
,但有錯誤象下面這樣:
undefined method `listings_charges_path' for #<#<Class:0x007f0690ea1788>:0x007f06b1864b88>
= form_tag listings_charges_path(@listings) do
是因爲收費嵌套在上市資源和上市也嵌套在另一個呢?這很奇怪,因爲如果我將代碼更改爲無嵌套資源,它完全正常工作。
= form_tag charges_path do
任何幫助真的很感激。
謝謝!
這個工作,但也有一些是新的:
= form_tag person_listing_charges_path(@person, @listing, @charges) do
新的錯誤:
No route matches missing required keys:{:action=>"index", :controller=>"charges", :id=>"111-abc", :listing_id=>nil, :locale=>nil, :person_id=>#<Listing id: 111, ..........} [:listing_id]
您還需要在路徑方法中傳遞'@ charge'對象。 –