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

[Question] How to includes to dependent destroy #620

Open
Piioo opened this issue Jul 28, 2022 · 0 comments
Open

[Question] How to includes to dependent destroy #620

Piioo opened this issue Jul 28, 2022 · 0 comments

Comments

@Piioo
Copy link

Piioo commented Jul 28, 2022

We have a model like this

class Consumer < ApplicationRecord
  has_many :offers, dependent: :destroy
end 

class Offer < ApplicationRecord
  has_many :incidents, dependent: :destroy
end

When we try to destroy the consumer with consumer.destory!
we get this unexpected error

Minitest::UnexpectedError:
       Bullet::Notification::UnoptimizedQueryError: user: pisz
       DELETE /consumers/b900b64f-1f30-4694-980f-4bbc029b5c10/delete
       USE eager loading detected
         Offer => [:incidents]
         Add to your query: .includes([:incidents])

How I may add includes to offer.incidents?

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

No branches or pull requests

1 participant