路线.rb
resources :project_associations, :only => [:update]
rake 路
project_association PUT /project_associations/:id(.:format) {:action=>"update", :controller=>"project_associations"}
再培训局
<%= 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”
我踢了服务器,同样的结果
在此先感谢您的帮助。
最佳答案
将此添加到 link_to
::method => :put
。
所以:
<%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command]), :method => :put %>
关于ruby-on-rails - RoR Routes 错误 : From a link_to built URL, 路由出现在 rake 路由中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7541537/