RoR 路由错误:从 link_to 构建的 URL,路由出现在 rake 路由中
routes.rb
resources :project_associations, :only => [:update]
rake 路由
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”
我踢了服务器,结果相同
提前感谢您的帮助。
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])%>
Resulting HTML
<a href="/project_associations/2011?command=suspend">Suspend</a>
Click result:
Routing Error
No route matches "/project_associations/2011"
I kicked the server, same result
Thanks in advance for any assistance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其添加到
link_to
中::method => :放
。所以:
Add this to the
link_to
::method => :put
.So: