我知道rails应该在生成灯具时禁用参照完整性。因此,经过快速谷歌搜索,我发现错误跟踪错误的解决方案是让我的postgres用户成为超级用户。错误:
WARNING: Rails was not able to disable referential integrity.:00, ETA: 00:00:00
This is most likely caused due to missing permissions.
Rails needs superuser privileges to disable referential integrity.
ActiveRecord::InvalidForeignKey: ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "responses" violates foreign key constraint "fk_rails_2ec3339f90"
DETAIL: Key (assessment_id)=(1) is not present in table "assessments".
: INSERT INTO "joe"."responses" ("assessment_id", "user_id", "question_id", "choice_id", "created_at", "updated_at") VALUES (1, 1, 1, 1, '2017-05-08', '2017-05-08')
我认为这将是一个简单的修复,但我的postgres用户已经是超级用户。我做了SHOW is_superuser;
,回复是on
。我甚至使用alter table responses disable trigger all;
使用同一用户从命令行手动禁用了所有触发器。当我使用\du
列出postgres用户时,属性显示为Superuser, Create role, Create DB
。
我非常确信我的用户是超级用户。这里一定有别的东西。我正在使用公寓宝石进行多租户。感谢帮助。如果您需要更多代码,请与我们联系。