Rails app Foreign key error: Administrative user not allowed to delete other users in Rails app Foreign key error: Administrative user not allowed to delete other users in heroku heroku

Rails app Foreign key error: Administrative user not allowed to delete other users in


To add an alternative for those who don't want to delete associated records (maybe you want to keep the cars records for later use).

class User < ActiveRecord::Base  ....  has_many :cars, dependent: :nullifyend

The associated record foreign_key will be set to nil.

Can be useful for people like me landing on your question!


Add cascading delete to yout User model:

class User < ActiveRecord::Base  ....  has_many :cars, :dependent => :delete_allend


creating a migration with

add_foreign_key :identities, :users, on_delete: :cascade

works for me. See also: https://stackoverflow.com/a/36137593/5521564