gpt4 book ai didi

ruby-on-rails - Rails Devise PG::SyntaxError: ERROR: ""处或附近的零长度分隔标识符“”

转载 作者:行者123 更新时间:2023-12-04 06:03:19 25 4
gpt4 key购买 nike

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

错误是 ActiveRecord::StatementInvalid in Devise::RegistrationsController#createPG::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

我应该在哪里寻找调试这个?我正在尝试调试设计 Controller ,但我找不到它。

谢谢。

最佳答案

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

class Doctor < ActiveRecord::Base 
set_primary_key :email
end

关于ruby-on-rails - Rails Devise PG::SyntaxError: ERROR: ""处或附近的零长度分隔标识符“”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27659752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com