Debugging is as important as writing code, it can cause your program to crash or behave unexpectedly. Most of the time, debugging can be very stressful, especially when one doesn’t use the right tools to debug. When I started building apps in rails, I used the helper method to inspect my code, but it got tiresome to type inspect on each data that I wanted to inspect, so I decided to spend some time learning debugging tools that made it easier and faster to debug. inspect In this article, I shall talk about a few tools that help me so much when I debug my code. Byebug Byebug is a gem which is automatically shipped with rails, you can find it in gemfile in your app directory. Byebug is a working breakpoint, this means you can inspect your data at any stage where you place the breakpoint, all you have to do is to type where you’d like to inspect and run the app. byebug Once the app reaches the breakpoint, the server hangs and a terminal appears and you can type anything that you’d like to inspect. Another great feature of byebug is that you continue or step into any function calls and inspect them too. It’s similar to the debugger in the console for JavaScript. To continue running the app until the next byebug command or the end of your application if you don’t have any, you simply type in the terminal, to step into and to move to the next line of code. continue step next byebug debugger placed on index action Use byebug to inspect books use next command to execute next line of code PRY Pry is very similar with byebug but it isn’t automatically shipped with rails, So you have to install it yourself. To install pry, simply add ‘pry-byebug’ gem in your gemfile then run install bundle or check out the pry’s documentation for more information. To use pry on your application, simple place the code below on where you’d like to inspect <% binding.pry %> using pry as a debugger Nicer syntax with pry An advantage of using pry over byebug is that pry returns a nicer format of the data you requested for, it also highlights the syntax of the code around the breakpoint. You can can place more than one "byebug" or "pry" in a single file and use ‘next’ to step into the next line of the code or 'continue' if you want your code to run till the end if there's only one "byebug" or pry in the file. To quit the pry terminal you should type ":q", to navigate up and down, you could use "j" and "k" respectively. Resources Check to get more information on byebug. https://github.com/deivid-rodriguez/byebug Check to get more information on pry. https://github.com/pry/pry Image source