IRB Shell And Ruby Debugger For Your Apps

Reading Time: < 1 minute

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.

Installation:

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.

Try

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

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

Controllers:

binding.pry

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 https://github.com/pry/pry/

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!

0 Shares:
You May Also Like

Fake it!

Reading Time: 3 minutesFake It! A couple of tools to generate fake data in your app. Hi, this time I want…