LoginSignup
3
1

More than 5 years have passed since last update.

inspectメソッド(ruby)

Posted at

inspectメソッドはオブジェクトに対して使うことでそのオブジェクトの内容がわかるような文字列を返してくれる。

user = User.find(1)
p user.inspect

出力結果

"#<User id: 1, name: \"test_user\", created_at: \"2018-10-06 16:45:52\", updated_at: \"2018-10-06 22:34:48\", email: \"xxx@x.x\", password: \"xxxxxxx\", remember_token: \"xxxxxxxx\", deleted: false>"
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