我试图在ROR视图页面中显示我的数据库中的类别下拉列表,我想在下拉列表中提供删除所选类别的链接。我写了以下代码,但它不起作用,请帮帮我
我的代码是:
index.html.erb
<%= collection_select(:catvalue, :id, @catvalues, :id, :v_name, {}, class: 'drop-down')%>
<%= link_to 'Destroy', {:catvalue => :id},method: :delete, data: { confirm: 'Are you sure?' } %>
和我的
控制器是:
class CatvaluesController < ApplicationController
def index
@catvalue = Catvalue.new
@catvalues = Catvalue.all
@categories = Category.all
end
def destroy
@catvalue_del = Catvalue.find(params[:id])
@catvalue_del.destroy
redirect_to catvalues_path
end
end
但它不起作用