I'm trying to flag N+1 and places in the code where I can add counter caches, using the bullet gem. But doing everything manually to check N+1 queries, seems very painfully, so I tried to use Bullet with Rspec, using the setup steps they recommend:
# config/environments/test.rb
config.after_initialize do
Bullet.enable = true
Bullet.bullet_logger = true
Bullet.raise = true # raise an error if n+1 query occurs
end
# spec/spec_helper.rb
if Bullet.enable?
config.before(:each) do
Bullet.start_request
end
config.after(:each) do
Bullet.perform_out_of_channel_notifications if Bullet.notification?
Bullet.end_request
end
end
But when I run the specs, seems to flag N+1 queries within specs itself rather than the app. Do you know if it's possible to achieve what I want?
this is actually a bug in the gem, please follow the issue here, comment and upvote for a faster resolution: https://github.com/flyerhzm/bullet/issues/407#issuecomment-437672707
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With