我已经与这个错误斗争了一段时间,我确信这是一个简单的东西,我错过了。我正在阅读jumpstartlabs(http://tutorials.jumpstartlab.com/projects/blogger.html#i3:-tagging)的博客2教程。
我试图通过UI实现一种删除现有标记的方法。我被困在试图解决这个错误:
没有路线匹配的帖子“/标签/3”
我的routes.rb是:
Blogger::Application.routes.draw do
root to: 'articles#index'
resources :articles do
resources :comments
end
resources :tags
end这是我的标签控制器:
class TagsController < ApplicationController
def show
@tag = Tag.find(params[:id])
end
def index
@tags = Tag.all
end
def destroy
@tag = Tag.find(params[:id])
@tag.destroy
flash.notice = "Tag '#{@tag.name}' Deleted!"
redirect_to action: 'index'
end
end最后,下面是我显示删除链接的页面:
<h1>All Tags</h1>
<ul id="tags">
<% @tags.each do |tag| %>
<li>
<%= link_to tag.name, tag_path(tag), class: 'tag_title' %>
<%= link_to "Delete", tag_path(tag), method: :destroy, data: {confirm: "Really delete the tag?"} %>
</li>
<% end %>
<%= link_to "<< Back to Articles List", articles_path %>
</ul>发布于 2014-07-15 16:52:39
正如@BillTurner所提到的,尝试将方法从:destroy更改为:delete。确保您保存了更改,重新启动了服务器,并让我知道这是否有效。
发布于 2016-05-29 19:52:48
这个答案对我没有用,但我在别处发现=>修好了它
<%= link_to "delete", article_path(@article), :method => :delete, data: {confirm: "Really delete the article?"} %> (在视图app\views\articles\show.html.erb中)
https://stackoverflow.com/questions/24747465
复制相似问题