Search⌘ K
AI Features

Basic Pry Consoling

Explore Pry console basics for troubleshooting and debugging within Rails. Learn to navigate object scopes, list methods, view source code, and handle exceptions to improve your Rails test development and debugging skills effectively.

Debugging examples

We’ve set Pry up as our Rails console, so we can access it with a simple rails console:

Terminal 1
Terminal
Loading...

Try running the following commands in the rails console:

C++
> 1 + 1
> project = Project.new(name: "Project Runway")

Examine object

Pry allows us to closely examine the current object under the scope, which we can determine with the self command. Right now, the current object is main:

Ruby
> self
> ls

Unix directory

Pry uses the Unix directory navigation metaphor to work through object trees. So, just as typing ls in a regular Unix terminal gives us a list ...