当我尝试从数据库中删除单个记录时,为什么会一直出错?轨道

时间:2013-07-02 19:47:04

标签: ruby-on-rails postgresql

我无法从数据库中删除记录。我一直收到这个错误。

PG::Error: ERROR: zero-length delimited identifier at or near """" LINE 1: ...ctive_items" WHERE "users_items"."" = $1 ^ : DELETE FROM "users_items" WHERE "users_items"."" = $1

这是方法。

def delete_items
    @destroyer = UsersItems.find_by_item_id(params[:items_id])
    @destroyer.destroy
    flash[:notice] = "Item deleted"
    redirect_to itemsearch_path

<a><%= link_to "Delete Item",{:controller => "items", :action => "delete_items",:method => :delete,:item_id => item.id}%></a>

1 个答案:

答案 0 :(得分:1)

改变这个:

<a><%= link_to "Delete Item",{:controller => "items", :action => "delete_items",:method => :delete,:item_id => item.id}%></a>

为此:

<%= link_to "Delete Item",{:controller => "items", :action => "delete_items", :item_id => item.id}, :method => :delete%>