LoginSignup
1
0

More than 3 years have passed since last update.

デバックツール pry-beybugの導入

Posted at

はじめに

変数を確認したり、メソッドを呼び出す為の、デバックツールの導入方法のメモになります。

Gemfileに記入する

Gemfile 記入前

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

Gemfile 記入後

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
 gem 'pry-byebug'
end

docker-compose buildを行う

docker-compose up -d

docker-compose psでコンテナを確認する

   Name                  Command               State           Ports
-----------------------------------------------------------------------------
rails_db_1    docker-entrypoint.sh mysqld      Up      3306/tcp, 33060/tcp
rails_web_1   bundle exec rails s -p 300 ...   Up      0.0.0.0:3000->3000/tcp

railsサーバーにアタッチを行う

docker attach rails_web_1

あとはデバックをしたい部分にbindng.pryを書くだけ。

デバッカーから抜けたい場合はexitかcontinueで抜ける。

アタッチを外したい場合はCtrlキーを押しながら、pキー、qキーの順に押す。

1
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
1
0