IRB Shell And Ruby Debugger For Your Apps

Reading Time: < 1 minutes

This great tip that I bring to you today guys, is something that I found when I was coding and got stuck trying to debug my application. I found this gem named PRY, a cool gem that allows you to have an alternative IRB shell and also works as a debugger for ruby.


Go to your Gemfile and write the following line:

gem pry

Then go to your terminal and:

$ bundle install

After that, pry will be ready to be used within your application.


You can use pry as a shell, but, also as a debugger.

You can use it in your controllers and in your views:



Views (ERB):

<%- binding.pry %>

Views (HAML):

- binding.pry

Restart your server

Go to your localhost app, and then browse to the page where you used the lines above. You will experiment a frozen website, now, you are ready to go to your console and see the received parameters, methods, etc.

If you want to stop just write:

$ exit

and your server will be running again.

If you want more information related to pry, go to its Github repository

Thanks for reding me!, I hope I have been of some help to you.

Follow me on twitter @zazvick and stay in touch!

Know more about us!

You May Also Like