Logistic&租赁请求通过TypeLogistic表彼此相关。我不小心创建了一个糟糕的TypeLogistic,所以现在有两个:
TypeLogistic.where(rental_request_id:200).where(logistic_id:130)
=> #<ActiveRecord::Relation [#<TypeLogistic rental_request_id: 200, logistic_id: 130, type_of_logistics: nil>, #<TypeLogistic rental_request_id: 200, logistic_id: 130, type_of_logistics: "delivery">]>
如何销毁第一个?尝试在下面跑,没有用
TypeLogistic.where(rental_request_id:200).where(logistic_id:130).first.destroy
PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: DELETE FROM "type_logistics" WHERE "type_logistics"."" = $1
^
答案 0 :(得分:0)
由于TypeLogistic连接表没有主键,因此抛出错误。顺便说一下,这是它出现的默认设置,因为我按照说明创建了连接表而没有改变任何内容。
此处的详细信息:Rails Devise PG::SyntaxError: ERROR: zero-length delimited identifier at or near """"
解决方案?添加主键,请参阅以下答案: