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

Order of before_destroy and acts_as_paranoid should not really matter #168

Open
thebravoman opened this issue Jun 29, 2020 · 1 comment
Open
Assignees
Labels

Comments

@thebravoman
Copy link

Given

class Episode < ApplicationRecord
   acts_as_paranoid
   before_destroy do 
      puts self.authors.count
   end
   has_many :authors, dependent: :destroy

and

class Episode < ApplicationRecord
   before_destroy do 
      puts self.authors.count
   end
   acts_as_paranoid 
   has_many :authors, dependent: :destroy

This for me outputs different size of authors. In the first case authors are already destroyed. Because of this I can not do anything with them in the before_destroy.

In the second case the authors are there.

Looking at the code like this I think it should not matter which comes first.

@mvz
Copy link
Contributor

mvz commented Jul 26, 2020

Hi @thebravoman, I dug into this a bit and indeed, it is surprising that this happens, even when looking at ActsAsParanoid's code.

@mvz mvz self-assigned this Jul 26, 2020
@mvz mvz added the bug label Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants