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.

binding.pryの使い方

Posted at

binding.pry自分の知らない新しい使い方

13: def save
=> 14: binding.pry
15: purchase = Purchase.create(user_id: user_id, item_id: item_id)
16: Address.create(postal_code: postal_code, prefecture_id: prefecture_id, town: town, address: address, building: building, phone_number: phone_number, purchase_id: purchase.id)
17: end

binding.pryで止まったところでその先の行を丸ごと入れます

15行目
[1] pry(#)> purchase = Purchase.create(user_id: user_id, item_id: item_id)
terminal
(19.1ms) BEGIN
 (pry):3:in save'
User Load (0.7ms) SELECTusers.* FROMusersWHEREusers.id= 2 LIMIT 1
↳ (pry):3:insave'
(0.5ms) ROLLBACK

ROLLBACKでその行が差し戻されているのでうまくいかないということが行ごとで明らかになります。
便利〜〜〜

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?