Skip to main content

conditional_breakpoints

⛓️ Set Conditional Breakpoints with Byebug

Conditional breakpoints stop execution only when specific conditions are met, preventing you from wading through irrelevant hits. Append an if clause to byebug or use Byebug’s break command to target the exact state that interests you.

# app/controllers/payments_controller.rb
class PaymentsController < ApplicationController
def update
@payment = Payment.find(params[:id])
byebug if @payment.amount > 1000 # Only break for large payments
@payment.process!
redirect_to @payment
end
end

This ensures you only pause when amount exceeds 1000, saving time during repetitive test runs.