Skip to main content

pry_rails_inspection

🔍 Leverage Pry-Rails for In-Depth Object Inspection

Pry-Rails replaces the standard Rails console with Pry, providing syntax highlighting, command history, and powerful introspection commands. Use binding.pry to jump into a context where you can explore object methods, change variables, or even redefine methods before continuing execution.

# Gemfile
gem 'pry-rails'
gem 'pry-byebug'

# app/models/order.rb
class Order < ApplicationRecord
def total_price
binding.pry # Pause here and inspect `self`
line_items.sum(&:price)
end
end

In the console prompt, type ls to list methods/variables or show-source Order to view class source.