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