bullet
bullet copied to clipboard
[Question] How to includes to dependent destroy
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?