Tricks with Pry – Live Editing

When I’m programming in Ruby, one of the most indispensable tools I’ve found is an awesome little ruby gem called Pry.

Pry lets me debug my code, pausing and giving me a live REPL wherever I put a breakpoint (‘binding.pry’) in my code.

Recently, I learned about Pry’s editor integration, which gives you the ability to open your code in an external editor, make changes to it, then go back to debugging in your Pry REPL. This is super handy, because it means you don’t have to restart your Pry session every time you make a code change!

My favorite Ruby editors at the moment are RubyMine and Sublime Text. As such, I wanted to set RubyMine as my default Pry editor.

To do this, edit (or create) the “~/.pryrc” file in your home directory, and put this code in it:

My buddy, Jason Waldrip also came up with this nifty little addition, which will let you easily open methods in an external editor (although any changes you make won’t be live-updated in your Pry session without reloading the class files that you edited):

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you a real person? *