所以我整晚都在努力解决这个问题......我基本上已经将我的资源设置为:
resources :projects do
resources :categories
end
在我的部分形式中,我有:
<%= form_for ([@project, @category]) do |f| %>
<% end %>
它给了我错误:
No route matches {:controller=>"categories", :format=>nil, :project_id=>#<Project id: nil, project_title: nil, user_id: nil, created_at: nil, updated_at: nil>}
Try running rake routes for more information on available routes.
我的类别路线如何:
project_categories GET /projects/:project_id/categories(.:format) categories#index
POST /projects/:project_id/categories(.:format) categories#create
new_project_category GET /projects/:project_id/categories/new(.:format) categories#new
edit_project_category GET /projects/:project_id/categories/:id/edit(.:format) categories#edit
project_category GET /projects/:project_id/categories/:id(.:format) categories#show
PUT /projects/:project_id/categories/:id(.:format) categories#update
DELETE /projects/:project_id/categories/:id(.:format) categories#destroy
发生了什么事,为什么这不起作用。我已经尝试了一切,我尝试将项目变量传递到渲染路径然后执行:(给我一个差异错误,抱怨类别未定义)
form_for project.categories.build do |f|
我什至尝试过
form_for ([project, project.categories.build]) do |f|
但这给了我与上面相同的错误。
有任何想法吗?我用谷歌搜索过,我读过文章,读过演讲......它一定很简单