3
1

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のテスト環境にデバッグ用の情報を表示する

Last updated at Posted at 2019-11-20

Viewファイル内に
<%= debug {変数} if Rails.env.development? %>
を追加すると、テスト環境で任意の変数の中身を出力することができます。

####@userの中身を確認したい時

<%= debug @user if Rails.env.development? %>

####paramsを確認したい時

<%= debug params if Rails.env.development? %>

/app/views/application.html.erbに記述することで、全てのページでの出力が可能です。

application.html.erbの最下部に<%= debug params if Rails.env.development? %>と記述した場合の表示。
 2019-11-20 19.57.13.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?