Rails Devise PG::SyntaxError: ERROR: 零长度分隔标识符位于或靠近“"“" [英] Rails Devise PG::SyntaxError: ERROR: zero-length delimited identifier at or near """"
问题描述
我正在尝试添加一个新的设计模型.当我使用 sign_up 路径时,我能够创建一个用户,但在保存新用户(医生)后抛出错误.该错误不是很有帮助,所以我希望有人能指出我正确的调试方向.
I'm trying to add a new devise model. When I use the sign_up path I'm able to create a user but throws an error after the new user (doctor) is saved. The error isn't very helpful so I'm hoping someone could point me in the right direction for debugging.
错误是ActiveRecord::StatementInvalid in Devise::RegistrationsController#create
PG::SyntaxError:错误:第 1 行或附近的零长度分隔标识符:...in_ip" = $4,"sign_in_count" = $5 WHERE "doctors"."" IS NULL^ : UPDATE "doctors" SET "current_sign_in_at" = $1, "current_sign_in_ip" = $2, "last_sign_in_at" = $3, "last_sign_in_ip" = $4, "sign_in_count" = $5 WHERE "doctors"."" IS NULL
我的架构是
create_table "doctors", id: false, force: true do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
end
add_index "doctors", ["email"], name: "index_doctors_on_email", unique: true, using: :btree
add_index "doctors", ["reset_password_token"], name: "index_doctors_on_reset_password_token", unique: true, using: :btree
我应该在哪里调试它?我正在尝试调试设计控制器,但我找不到它.
where should I be looking to debug this? I'm trying to debug the devise controller but I can't find it.
谢谢.
推荐答案
您的表中需要一个主键,如果您不想使用 id 作为主键,您可以在模型中定义其他主键,例如这个:
You need a primary key in your table, if you don't want to use an id as primary key, you can define in the model other primary key like this:
class Doctor < ActiveRecord::Base
set_primary_key :email
end
这篇关于Rails Devise PG::SyntaxError: ERROR: 零长度分隔标识符位于或靠近“"“"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!