我无法从数据库中删除记录。我一直收到这个错误。
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>
答案 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%>