0

我创建了这样的嵌套路由

  resources :subjects do
    resources :subject_edits do
      member do
        post :vote
      end
    end
  end

当我运行时rake routes,我发现它退出了

vote_subject_subject_edit POST   /subjects/:subject_id/subject_edits/:id/vote(.:format) subject_edits#vote

但是当我在我的 .erb 文件中使用它时

<%= button_to 'I Agree', :action => vote_subject_subject_edit_path(@subject, @edit) %>

我有一个错误,

没有路线匹配 {:action=>"/subjects/25/subject_edits/1/vote", :subject_id=>"25", :id=>"1", :controller=>"subject_edits"}

这里有什么问题?

4

1 回答 1

0

这个助手显式设置 url,所以你需要:

<%= button_to 'I Agree', vote_subject_subject_edit_path(@subject, @edit) %>

没有通过:action选项。

于 2013-07-05T11:20:15.407 回答