【问题标题】:RoR Routes Error: From a link_to built URL, route appears in rake routesRoR 路由错误:从链接到构建的 URL,路由出现在 rake 路由中
【发布时间】:2011-11-24 09:17:27
【问题描述】:

routes.rb

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

搜索路线

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 用于在调试过程中启动服务器

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


【解决方案1】:

将此添加到link_to:method =&gt; :put

所以:

    <%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command]), :method => :put %>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-12-08
  • 2021-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多