路线
resources :links, only: [:new, :create, :index, :destroy]
链接控制器
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>
为什么我会收到此错误?