Rails路由资源成员问题

时间:2013-07-05 11:18:34

标签: ruby-on-rails routes

我已经创建了像这样的嵌套路线

  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 =&gt;“/ subjects / 25 / subject_edits / 1 / vote”,   :subject_id =&gt;“25”,:id =&gt;“1”,:controller =&gt;“subject_edits”}

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

此助手明确设置了url,因此您需要:

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

没有传递:action选项。