2
我無法讓我的form_for工作的嵌套資源,它瘋狂。rails 4嵌套資源無法獲取form_for工作
路線:
namespace :teacher do
resources :lessons do
resources :questions
resources :invites
resources :responses
end
end
應用程序/視圖/教師/問題/ _form.html.haml:
= simple_form_for [:teacher, @question], :html => { :class => 'form-horizontal form-lineup' } do |f|
..
指數顯示,正確銷燬行動的所有工作。打電話時 只有編輯操作失敗:
teachers/1/questions/1/edit
拋出:您提供的路由定義
No route matches {:action=>"show", :controller=>"teacher/questions", :teacher_id=>#<Teacher::Question id: 1, teacher_id: 5, user_id: nil, name: "asdf", email: "dsafsd", expire_at: "2013-12-23 19:36:00", created_at: "2013-12-23 19:36:25", updated_at: "2013-12-23 19:36:25">, :id=>nil, :format=>nil} missing required keys: [:id]
這些文檔還指出了我在此刻實施的多個/雜誌/:magazine_id/ads \t。問題似乎是我的_form中的form_for行,路由本身沒問題(它顯示編輯表單,當我從它移除這個form_for標記時): – Rubytastic
好的,我看到你的觀點,感謝你的寫作。在這種情況下?namespace:teacher do resource:teacher? – Rubytastic
如果你想產生這個路徑'teachers/1/questions/1/edit',你需要這樣定義路徑: 'resources:teachers do resources:問題 結束 – Gjaldon