Rails 3.2.11を実行すると、基本的に拡張されたスキャフォールドであり、AJAXリクエストに使用される4つの追加のGETメソッドによって拡張された通常のコントローラー「LbuController」があります。
resources :lbus do
get 'add_offering'
get 'remove_offering'
get 'add_offering_element'
get 'remove_offering_element'
end
ランニングrake routes
すると次のルートが表示されます
lbu_add_offering GET /lbus/:lbu_id/add_offering(.:format) lbus#add_offering
lbu_remove_offering GET /lbus/:lbu_id/remove_offering(.:format) lbus#remove_offering
lbu_add_offering_element GET /lbus/:lbu_id/add_offering_element(.:format) lbus#add_offering_element
lbu_remove_offering_element GET /lbus/:lbu_id/remove_offering_element(.:format) lbus#remove_offering_element
lbus GET /lbus(.:format) lbus#index
POST /lbus(.:format) lbus#create
new_lbu GET /lbus/new(.:format) lbus#new
edit_lbu GET /lbus/:id/edit(.:format) lbus#edit
lbu GET /lbus/:id(.:format) lbus#show
PUT /lbus/:id(.:format) lbus#update
DELETE /lbus/:id(.:format) lbus#destroy
それはまさに私が意図したもののようです。
http://localhost:3000/lbus/new
しかし、 created withへのリンクをたどるlink_to "new", new_lbu_path
と、次のエラーが発生します。
No route matches {:action=>"add_offering", :lbu_id=>nil, :offering_id=>1, :controller=>"lbus"}
これは私にはまったく意味がありません。ここで何が起こっているのか、何が間違っているのか、誰かが何か考えを持っていますか?
前もって感謝します!