I understand that rails is supposed to disable referential integrity when generating the fixtures. So after a quick Google search, i figured out that the solution to the error following error is to make my postgres user a super user. The error:
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')
I thought it would be an easy fix, but my postgres user is already a superuser. I did SHOW is_superuser; and the response was on. I even disabled all of the triggers manually from the command line with the same user using alter table responses disable trigger all;. When I list the postgres users using \du, the attributes show up as Superuser, Create role, Create DB.
I am very confident that my user is a superuser. There must be something else going on here. I am using the apartment gem for multi-tenancy. Help is appreciated. If you need any more code, let me know.
Aucun commentaire:
Enregistrer un commentaire