RoR路由错误:从link_to构建的URL,路由出现在rake路由中

时间:2011-09-24 19:57:52

标签: ruby-on-rails routing link-to

的routes.rb

resources :project_associations, :only => [:update]

rake routes

project_association PUT    /project_associations/:id(.:format)  {:action=>"update", :controller=>"project_associations"}

ERB

<%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command])%>

结果HTML

<a href="/project_associations/2011?command=suspend">Suspend</a>

点击结果: 路由错误 没有路线匹配“/ project_associations / 2011”

我踢了服务器,结果相同

提前感谢您的任何帮助。

1 个答案:

答案 0 :(得分:2)

将其添加到link_to:method => :put

所以:

    <%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command]), :method => :put %>