InvalidForeignKey Apartment Gem创建记录时

时间:2016-12-14 13:22:42

标签: ruby-on-rails ruby apartment-gem

我在公寓初始化程序文件中排除了用户模型。

config.excluded_models = %w{Franchise User Franchiser}

我在项目和用户之间有一个三元模型,但是当我添加成员时,它会在错误之下。

ActiveRecord::InvalidForeignKey (PG::ForeignKeyViolation: ERROR:  insert or update on table "members" violates foreign key constraint "fk_rails_2e88fb7ce9"
DETAIL:  Key (user_id)=(6) is not present in table "users".
: INSERT INTO "members" ("user_id", "project_id", "created_at", "updated_at", "email") VALUES ($1, $2, $3, $4, $5) RETURNING "id"):

任何帮助都将得到帮助。

0 个答案:

没有答案