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.

すぐに役立つRails tutorial メモ 「デバッグ」

Posted at

##何かわけのわからない挙動やエラーが見受けられた時に役に立つのがdebug メソッド

class UsersController < ApplicationController

  def show
    @user = User.find(params[:id])
    debugger
  end

  def new
  end
end

debuggerをshowアクションの中に入れることで、ターミナルにてbyebugプロンプトを確認することができます。

debugをやめたい時にはCtrl-Dを押すとプロンプトから抜け出すことができます。

debugメソッドを使うにはbyebug gemをインストールしている必要があります!

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?