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

Is there a way to only enable Bullet for certain controllers? #722

Open
obie opened this issue Nov 1, 2024 · 2 comments
Open

Is there a way to only enable Bullet for certain controllers? #722

obie opened this issue Nov 1, 2024 · 2 comments

Comments

@obie
Copy link

obie commented Nov 1, 2024

I'm on a very large app and only want to use Bullet for the specific controllers that I'm currently working on. I see a way to skip but not the opposite.

@flyerhzm
Copy link
Owner

flyerhzm commented Nov 2, 2024

@obie I have a solution but I didn't verify it yet.

  1. Enable the bullet globally.
  2. Skip it in ApplicationController for all requests, see the README.
  3. Enable it again in specific controllers, you can reverse the skip code.

@blombard
Copy link

In ApplicationController, you can add:

def enable_bullet
  previous_value = Bullet.enable? if defined?(Bullet)
  Bullet.enable = true if defined?(Bullet)
  yield
ensure
  Bullet.enable = previous_value if defined?(Bullet)
end

And then in your controllers:

around_action :enable_bullet, only: ...

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

3 participants