【问题标题】:Rails No route matches [DELETE]Rails 没有路线匹配 [DELETE]
【发布时间】:2017-11-25 20:11:45
【问题描述】:

试图删除回复

 <% @comment.replies.each do |reply| %>
 <td><%= link_to 'Destroy', comment_replies_path(reply), method: :delete, data: { confirm: 'Are you sure?' }%></td>

我确实收到以下错误

No route matches [DELETE] "/comments/66/replies"

搜索路线

comment_reply_path  
          DELETE    /comments/:comment_id/replies/:id(.:format)   replies#destroy

我此时的网址是

http://localhost:3000/comments/66/replies

routes.rb

resources :comments do
   resources :replies
end

【问题讨论】:

  • 你的 routes.rb 里有什么?
  • @SebastianPalma 已更新

标签: ruby-on-rails database oop


【解决方案1】:

您的路线显示comment_reply_path,而您正在使用comment_replies_path

您需要更新代码以使用正确的路径助手

<%= link_to 'Destroy', comment_reply_path(reply), method: :delete, data: { confirm: 'Are you sure?' }%>

【讨论】:

  • 我不知道该怎么做
  • 你有这样的链接
猜你喜欢
  • 1970-01-01
  • 2012-01-30
  • 2012-03-06
  • 1970-01-01
  • 1970-01-01
  • 2012-10-11
  • 2017-07-13
  • 1970-01-01
  • 2013-12-31
相关资源
最近更新 更多