0
0

【Rails】Bulletの導入方法

Posted at

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.rbconfig/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

カスタム構成については以下をご参照ください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0