0
路由沒有路由匹配{:行動=> 「消滅」,:控制器=> 「鏈接」}
resources :links, only: [:new, :create, :index, :destroy]
links_conttroller
class LinksController < ApplicationController
before_filter :signed_in_user
def new
@user = current_user
@tags = @user.tags
@link = Link.new
end
def create
@link = Link.new(params[:link])
if @link.save
flash[:success] = "Link created!"
redirect_to root_url
else
render 'new'
end
end
def index
@links = Link.paginate(page: params[:page])
end
def destroy
@link.destroy
redirect_to links_path
end
end
html.erb
<li>
<span class="location_info"> From Tag: <%= link.from_tag.ref %></span>
<span class="location_info"> To Tag: <%= link.to_tag.ref %></span>
<span class="location_info"> Cost: <%= link.value %>
| <%= link_to "delete", link, method: :delete,
data: { confirm: "You sure?" } %></span>
</li>
爲什麼我得到這個錯誤?
摧毀行動需要一個'ID',因此它可以搜索記錄(在你的情況下,它需要一個ID來搜索@鏈接) – jvnill 2013-03-12 14:48:37
這沒有幫助! – eoghanm 2013-03-12 14:55:42
你應該看看你得到這個錯誤的代碼。它很可能是在您嘗試添加刪除鏈接的視圖中。 – jvnill 2013-03-12 15:02:55