抱歉,如果其他地方有人问过这个问题,但我无法弄清楚。我有一个包含版块、主题和回复的论坛。我正在尝试从显示主题视图中编辑和删除回复。这是结构:
resources :sections do
resources :topics do
resources :replies
end
end
所以我做了一个 rake 路由来查看我在哪里链接我的编辑回复。我看到它的 edit_section_topic_reply 并在我的 link_to 中添加了 _path 。现在这是我无法弄清楚的。我要传递什么参数?不应该是:
<%= link_to 'Edit', edit_section_topic_reply_path(@reply, @topic, @section) %>
I get a ActionController::RoutingError
in Topics#show
当我这样做的时候。
No route matches {:topic_id=>#<Topic id: 2, section_id: 2, user_id: nil, subject: "subject", body: "body", created_at: "2011-03-04 08:37:37", updated_at: "2011-03-04 21:37:16">, :controller=>"replies", :action=>"edit", :section_id=>nil, :id=>#<Section id: 2, name: "Section", description: "Section Description", created_at: "2011-03-04 07:50:56", updated_at: "2011-03-04 07:50:56">}
看起来好像没有传递ID,但是之前的嵌套,我的新主题工作正常
new_section_topic_reply_path(@topic, @section)