的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”
我踢了服务器,结果相同
提前感谢您的任何帮助。
答案 0 :(得分:2)
将其添加到link_to
::method => :put
。
所以:
<%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command]), :method => :put %>