

This is what you will see when you are dropped on a pry session:

What I like to do is to have a macro/snippet on my editor that already includes the require in the same line than the breakpoint, so when I delete it I will be deleting both things. That won't be very helpful for a rails app, so you may want to add pry to your Gemfile. If you just want to do it temporarily then you can call your ruby script like this: You will also need to require pry into your project (require 'pry').
RUN RUBY MINE TERMINAL AS ADMIN INSTALL
Using pry you can make your code stop at a specific line of code (also known as a breakpoint) and it will drop you into an irb-like environment, where you can evaluate ruby code in the context of your project, or execute one of the many useful pry commands.Īll you have to do is drop binding.pry where you would like to install a pry breakpoint. When you have many variables to check, adding puts everywhere might not be very practical. Using p is equivalent to saying puts variable.inspect, and it’s useful for looking at objects.

The most basic (which doesn’t necessarily mean bad) debugging technique that you are probably familiar with is just dumping the values of the suspected variables.
RUN RUBY MINE TERMINAL AS ADMIN HOW TO
Using the techniques discussed in this article you will learn how to deal with this issue and similar problems! Understanding Errors & Stack Traces This means that a nil value managed to find it’s way into our code. You may be familiar with the following error message: undefined method 'some_method' for nil:NilClass Many times our programs dont’t work like we expect, so we have to use the art of debugging ruby to help us finding out why. How often does your program do exactly what you want the first time around?
