DEV Community

Doug Jones
Doug Jones

Posted on

Bug Tools

So in my last blog I spoke about how we as developer's break down big problems into little one's. That being said the next question is what tools do we use to help us solve these problems.

As developers debugging comes with the territory.

Let's look at some of our tools.

Binding.pry

 Binding.pry allows us to run our code up to a certain point and then stop it. Allowing us to check different aspects of our code up to that point. This way we can insure that our code is working as we intended it to work. With binding.pry stoping our code example. We can now check to the params for this method, the return value of @user and others aspects of this code up to this point. 
Enter fullscreen mode Exit fullscreen mode

Alt Text

Byebug

 Byebug is very similar to binding.pry. But it offers more functionality to us. One of the biggest differences with using byebug is that we are able to move through our code while testing it. So we are able to test more of our code without leaving the pry session.     
Enter fullscreen mode Exit fullscreen mode

Alt Text

Rails Console

 Rails console gives us a couple of options that we don't have with binding.pry or byebug. Similar to our pervious two tools we can check aspects of our code to insure we are getting the results we want. But rails console also allows us to create data that we can persist to our database. If we wanted the option to test our code without persisting to the database we also have the option of opening up a sandbox in the console with the rails c -s command. Using the rails console sandbox. We are able to create data and test it but It will not persist to the database. 
Enter fullscreen mode Exit fullscreen mode

Alt Text

Hopefully this has been a helpful in giving you a look into some option in your debugging/coding journey.

Top comments (0)