Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double acts_as_paranoid by mistake #489

Closed
gus4no opened this issue Mar 27, 2020 · 0 comments · Fixed by #492
Closed

double acts_as_paranoid by mistake #489

gus4no opened this issue Mar 27, 2020 · 0 comments · Fixed by #492

Comments

@gus4no
Copy link

gus4no commented Mar 27, 2020

Hi, this is more like a question not a real issue, it's because of a bug that was driving me crazy.

We had some resources that were raising some foreign key exceptions:

PG::ForeignKeyViolation: ERROR: update or delete on table "a" violates foreign key constraint "fk_rails_f207f40ee2" on table "b"

For some reason, calling really_destroy! was not destroying associations it was just updating it's deleted_at column but this was only happening on one association (all of the associations have dependent :destroy), after a lot of debugging and testing I realized that in a bad merge (probably) we had a duplicate call to acts_as_paranoid so we had.

Class A < ActiveRecord::Base
  acts_as_paranoid
  acts_as_paranoid
end

I then took one of those calls out, and then it all started working properly.

I opened up the source code to try to understand what the heck was going on, and why having that double call to acts_as_paranoid makes the association to be soft deleted instead of really destroyed.

So that's why I'm here, just trying to understand what's happening and in case somebody else has an issue like this.

Rails 4.2.11.1
Paranoia 2.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant