Debugging Rails Like a Pro
binding.pry, two words that have the ability to freeze your program in time and in IRB, gives you a more powerful way to debug. Once you have the gem installed, you can simply put the binding.pry command anywhere in your application (usually before the line of code that is breaking your app). In IRB, you will see the pry session along with the lines of code before and after it. In this session, you can do things like check to see if your variables are accurate and you can easily test out methods.
Here are some useful Binding Pry Commands:
whereami - reprints where you are in the pry session
ls - lists all the variables, methods, modules available in the current scope
wtf - will print the most recent error stack trace (it identifies the error, from the most specific context to the most general context)
exit - binding.pry session can be used inside a loop to check each iteration for errors. Typing 'exit' while inside that current pry session will take you out of the session and trigger again.
Read more about Pry here: http://pryrepl.org/








