---
title: Better Rails Debugging with better_errors and jazz_hands
description: Go beyond the stacktrace with 2 gems that grant you debugging superpowers.
image: https://resources.mutuallyhuman.com/hubfs/Imported_Blog_Media/default-c8c8d382f67a78409ccf066a91cc6e54f495a0e76b9ba8764b833c1e81dd2eb4-1.png
---

[Home](https://mutuallyhuman-pr-605.herokuapp.com/)

- [Team](https://mutuallyhuman-pr-605.herokuapp.com/team)
- [Work](https://mutuallyhuman-pr-605.herokuapp.com/work)
- [Blog](https://mutuallyhuman-pr-605.herokuapp.com/blog)
- [Contact](https://mutuallyhuman-pr-605.herokuapp.com/contacts)

# Better Rails Debugging with better\_errors and jazz\_hands

By [Ross Hunter](https://resources.mutuallyhuman.com/test/author/ross-hunter) on 16 05 2013

## Better Errors

Does this screen look familiar? Do you notice anything wrong with this picture?

![default error page](https://resources.mutuallyhuman.com/hubfs/Imported_Blog_Media/default-c8c8d382f67a78409ccf066a91cc6e54f495a0e76b9ba8764b833c1e81dd2eb4-1.png)

That is correct, that is the default Rails error page and you are absolutely right, it is completely hideous and hurts to look at. It is begging to be improved.

By answering these questions you have already proven yourself to be quite a smart cookie, my dear reader, so you probably can guess what a gem called [`better_errors`](https://github.com/charliesome/better_errors) does. However, you might not realize just how much of an improvement `better_errors` actually is.

 Basic `better_errors` stats:

- Full stack trace
- Source code inspection for all stack frames (with highlighting)
- Local and instance variable inspection
- Live REPL on every stack frame

![better_errors error page](https://resources.mutuallyhuman.com/hubfs/Imported_Blog_Media/better_errors-cd832e74eca03b301136b176537d3a8b23663318b4eb2aabeb227dfbc73beac5-1.png)

It is clearly more visually appealing, but it also provides much more detailed debug information, as well as providing a REPL for interacting with the code (assuming you have the separate [`binding_of_caller`](https://github.com/banister/binding_of_caller) gem installed).

One of my favorite parts of better\_errors is that it filters application frames in the stacktrace, so when debugging you can focus (at least at first) on the code *you* are writing and less on the Rails internals. The flipside of that is that by showing you a little bit of code context, as well as local variables, instance variables, request info, and providing a REPL for the full stacktrace, it is much easier to examine those Rails internals and pick up on that Rails Magic™ going on.

If you are debugging a Rails API, AJAX, want to investigate a non-critical error like missing images, or for any other reason don't access the error page directly at the time of the error `better_errors` provides a page accessible via the url "/\_\_better\_errors" which contains the error page for the last error on the server.

Another awesome part of `better_errors` is that it can open up files in your editor! It comes out of the box with support for textmate, but also supports for vim and a couple other editors. You can add Sublime Text by downloading [sublime-handler](https://github.com/asuth/subl-handler) and configuring an initializer for `better_errors` that simply contains:  
 BetterErrors.editor = :sublime if defined? BetterErrors

The error page page is even responsive! This is an extremely polished gem and I simply can't live without it.

## Jazz Hands

When I need to really get my mitts in there and dig around for debugging, I like to use [`jazz_hands`](https://github.com/nixme/jazz_hands).

`jazz_hands` is collection of gems built around the popular IRB replacement `pry`. It includes:

- Pry for a powerful shell alternative to IRB.
- Awesome Print for stylish pretty print.
- Hirb for tabular collection output.
- Pry Rails for additional commands (show-routes, show-models, show-middleware) in the rails console.
- Pry Doc to browse Ruby source, including C, directly from the console.
- Pry Git to teach the console about git. Diffs, blames, and commits on methods and classes, not just files.
- Pry Remote to connect remotely to a Pry console.
- Pry Debugger to turn the console into a simple debugger.
- Pry Stack Explorer to navigate the call stack and frames.
- Coolline and Coderay for syntax highlighting as you type. Optional. MRI 1.9.3/2.0.0 only

This is not intended to be an exhaustive tutorial on how to debug using `pry`, but suffice it to say I mostly interact with `pry` by setting breakpoints with `binding.pry` in my source code to launch the pry REPL in the terminal running my rails server. `better_errors` is great at catching exceptions and helping to isolate a problem by showing the stacktrace, but once you know the problem and need to experiment in order to figure out the solution, `pry` is a much more powerful tool than the REPL provided by `better_errors`.

The part of the `jazz_hands` extension that I interact with the most is `awesome print`. This provides a prettier output in the REPL when getting descriptions of objects and variables. `pry-debugger` is also great for allowing you to step through the code right from the REPL. `pry-rails` is great and I find myself using the show-routes functionality frequently.

![colored output](https://resources.mutuallyhuman.com/hubfs/Imported_Blog_Media/jazz_hands-3bd0d4224095e42692e9174a8ab339daf87478b5fbe91267951f419a80e9f0e1-1.png)  
![show routes](https://resources.mutuallyhuman.com/hubfs/Imported_Blog_Media/show-routes-c23f3f3645f8d9815b149e7f2be509d5e63f1e74ef41b3e3acc09706a05519c6-1.png)

I have found `pry-git` to be quite buggy and have not been able to use it successfully. The syntax highlighting as you type technically works, but oddly it causes my cursor to be offset by 10 or so characters to the right, so I don't use it.

## In Conclusion

One of the best things about [`jazz_hands`](https://github.com/nixme/jazz_hands) and [`better_errors`](https://github.com/charliesome/better_errors) is that they are so simple to set up and have no downsides. These gems are my defaults and are in every single rails project I do. By giving you debugging superpowers these gems can not only be huge time-savers, but they can reduce your stress to add years to your life. Not every gem can say that!

### Related Topics

- [Uncategorized (106)](https://resources.mutuallyhuman.com/test/topic/uncategorized)
- [User Experience (20)](https://resources.mutuallyhuman.com/test/topic/user-experience)
- [Ruby (11)](https://resources.mutuallyhuman.com/test/topic/ruby)
- [Interaction Design (10)](https://resources.mutuallyhuman.com/test/topic/interaction-design)
- [JavaScript (9)](https://resources.mutuallyhuman.com/test/topic/javascript)

### Related Posts

### About Mutually Human

Mutually Human is a custom software design and development consultancy specializing in mobile and web-based products and services. We help our clients design, develop and bring to market innovative products and services based on insightful research and strategy aligned with business objectives. We’ve helped Fortune 500 companies, state governments, and startups.

- [Home](https://www.mutuallyhuman.com)
- [Team](https://www.mutuallyhuman.com/team)
- [Work](https://www.mutuallyhuman.com/work)
- [Blog](https://www.mutuallyhuman.com/blog)
- [Contact](https://www.mutuallyhuman.com/contacts)

logo

[Mutually Human Grand Rapids: 401 Hall St. SW Suite 430 Grand Rapids, MI 49503 USA](https://www.mutuallyhuman.com/contacts#grand-rapids)

[Mutually Human Columbus: 243 N. Fifth Street Suite 300 Columbus, OH 43215 USA](https://www.mutuallyhuman.com/contacts#columbus)

+1 616 475-4225

[hello@mutuallyhuman.com](mailto:hello@mutuallyhuman.com)

<https://twitter.com/mutuallyhuman/><https://www.linkedin.com/company/mutually-human-software> <https://www.facebook.com/mutuallyhuman/> <https://github.com/mhs>

© 2017 Mutually Human