Junior Track Roadmap

Debugging: binding.irb mastery

This course covers binding.irb, a line of Ruby that pauses a running method and opens an IRB prompt inside its scope. It compares this with puts debugging, where every question must be planned before a rerun. It explains how Kernel#binding captures the local scope and how Binding#irb opens a nested session. It shows inspecting locals, self and instance variables, resuming with continue or exit, and stepping with next through the debug gem. It ends by using binding.irb inside a Rails app through bin/rails runner.

What you'll learn

  • ✓Why puts debugging forces you to plan every question before rerunning
  • ✓How Kernel#binding and Binding#irb combine to open a prompt in a method's scope
  • ✓Inspecting local variables, parameters, self and instance variables at a paused line
  • ✓Resuming with continue or exit and stepping line by line with next
  • ✓When to use binding.irb and when to use puts or logging
  • ✓Using binding.irb with real models inside a Rails app through bin/rails runner
Free preview · Lesson 1 2 min read

Beyond puts: live state inspection

A typical first debugging move: sprinkle puts calls through a method and rerun the whole program. You read what printed, decide it wasn't enough, add more puts calls, and rerun again.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...