我试图条纹添加到下面这个教程我的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'对象。 –