0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pry-byebug 【Railsのデバッグツール】

Posted at

【pry-byebug】

Ruby on Railsを使用した実際の現場でも使われている。
このようなデバッグは初めてなのでしっかり抑えたい。

pry-byebugのインストール

開発時のみ必要なgemは、group :developmentのブロック内に追記。
 → 本番環境に不要なので、ここに書く。

Gemfile
group :development do

   gem 'pry-byebug'

Docker環境でpry-bybugを使おう

$docker ps
 → デバッグ対象のコンテナを確認

$docker attach < コンテナ名 >
→ コンテナ名を指定して、アタッチする。

デバッグをおこないたいファイルに、binding.pryを入力する。

binding.pryの位置でプログラムが一時停止する。
 → 任意のコードを実行することができる。

exitコマンドでプログラムの一時停止を解除する。
その後、不要になったbinding.pryを消しておく。

コンテナのアタッチ解除するには。
 → Ctrl押しながら、pキーを押して、qキーを押す。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?