Rails设计PG :: SyntaxError:错误:在“”“或附近的零长度分隔标识符

我正在尝试添加一个新的设计模型。 当我使用sign_up路径时,我能够创建用户,但在保存新用户(医生)后会抛出错误。 错误不是很有帮助,所以我希望有人能指出我正确的调试方向。

错误是ActiveRecord::StatementInvalid in Devise::RegistrationsController#create

PG::SyntaxError: ERROR: zero-length delimited identifier at or near """" LINE 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 

我应该在哪里调试这个? 我正在尝试调试设备控制器,但我找不到它。

谢谢。

您需要表中的主键,如果您不想使用id作为主键,则可以在模型中定义其他主键,如下所示:

 class Doctor < ActiveRecord::Base set_primary_key :email end