我无法让我的 form_for 为嵌套资源工作,而且它快疯了。
路线:
namespace :teacher do
resources :lessons do
resources :questions
resources :invites
resources :responses
end
end
app/views/teacher/questions/_form.html.haml:
= simple_form_for [:teacher, @question], :html => { :class => 'form-horizontal form-lineup' } do |f|
..
index、show、destroy 动作都可以正常工作。调用时只有编辑操作失败:
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]