生成灯具时出错.Rails无法禁用参照完整性

Dyl*_*erg 5 ruby testing postgresql ruby-on-rails fixtures

我知道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')
Run Code Online (Sandbox Code Playgroud)

我认为这将是一个简单的解决方案,但我的postgres用户已经是超级用户.我做SHOW is_superuser;了,回应是on.我甚至使用相同的用户从命令行手动禁用了所有触发器alter table responses disable trigger all;.当我列出使用的postgres用户时\du,属性显示为Superuser, Create role, Create DB.

我非常有信心我的用户是超级用户.这里一定有别的东西.我正在使用公寓宝石进行多租户.感谢帮助.如果您需要更多代码,请告诉我们.

Jer*_*ome 0

config/database.yml- say中指定的用户rails_deploy_user需要定义超级用户权限,而不是通用的 postgres 用户。

psql database_environment
\du;  # find psql defined users and roles
ALTER ROLE rails_deploy_user WITH SUPERUSER;
Run Code Online (Sandbox Code Playgroud)