Gemをインストール
Gemfile
に以下のように記述し、 bundle install
します。
Gemfile
group :development do
gem "bullet", "~> 7.2"
end
設定する
ターミナルで以下のコマンドを実行し、設定を自動生成します。
$ bundle exec rails g bullet:install
Enabled bullet in config/environments/development.rb
Would you like to enable bullet in test environment? (y/n) y
Enabled bullet in config/environments/test.rb
config/environments/development.rb
と config/environments/test.rb
に次のような設定が生成されます。
config/environments/development.rb
Rails.application.configure do
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
Bullet.rails_logger = true
Bullet.add_footer = true
end
end
config/environments/test.rb
Rails.application.configure do
config.after_initialize do
Bullet.enable = true
Bullet.bullet_logger = true
Bullet.raise = true # raise an error if n+1 query occurs
end
end
カスタム構成については以下をご参照ください。