LoginSignup
1
2

More than 3 years have passed since last update.

[Rails] cloud9でのデバッグ方法

Posted at

結論

処理を止めたい場所で"debugger"と打ち込む

  def create
    @voice = Voice.new
    @voice.user = current_user
    @voice.voice = params[:voice][:voice]

  debugger

    if @voice.save
      redirect_to @voice, notice: 'Voice was successfully created.'
    else
      render :new
    end
  end

この状態でプレビュー画面にて処理を実行。(この場合だとcreateの処理を実行)

すると

debugger.png

プレビュー画面が停止し、debuggerが起動される。

矢印の部分に変数などを入力することで、処理を止めた時点での変数の値を確認することができる。

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