flyerhzm/bullet

How Can I Use Bullet Gem in a Thor Task Job ?

irep-phong-pham opened this issue · 1 comments

I've set up Bullet gem in my rails servẻ to inspect N+1 problems.
It worked normally.

But when I run a thor task job it seems not working at all.

Here's my set up:

# frozen_string_literal: true

Rails.application.configure do
  ...

  config.after_initialize do
    Bullet.enable = true
    Bullet.bullet_logger = true
    Bullet.raise = true
    Bullet.unused_eager_loading_enable = false
  end
end

Here's my thor set up:

require "thor"
require "logger"
require File.expand_path("config/environment", __dir__)

# Thorfile
class Batch < Thor

  APPLICATION_RB = "../config/application.rb".freeze

  ...
end

@irep-phong-pham you can use the following code

Bullet.profile do
# your code
end