Is the rails 4.2 web-console gem a complete replacement for the better_errors gem or do I need to look at the features of each to work out which one I will prefer?
2 Answers
They're not the same thing.. The web-console even recommends better_errors on it's README:
Check out better_errors as a great alternative for any Rack application!
The advantage of web-console is that you can start a console session calling debug
anywhere in your files or views, pretty much like binding.pry
(from pry gem) always did.
The better_errors is an improved error screen that happens to have a console session on the sidebar (if you use the binding_of_caller gem with it).
IMO, you can use both gems.. no need to choose one or another.

- 7,732
- 5
- 43
- 64
-
2Aren't they both quite similar in that they provide you with a console for debugging? Although the quote you gave is no longer in the README perhaps it is good advice, use better_errors for a Rack application and web-console for a Rails app? Why would we want to use both (serious question, not trolling)? Also, I believe we now call **console** rather than **debug** – Marklar Mar 11 '15 at 20:02
-
2@Marklar there are some benefits to better_errors. The page it shows for errors is nicer and gives better information about the current state. On the other hand, web-console provides the console on every page, including those that have loaded correctly. – Josh Johnson Jul 07 '15 at 19:26
-
better_errors returns useful error responses to AJAX requests, and provides a manual console to inspect the most recent exception, even if it occurred in an AJAX request. web-console does not have this, though it does have a way to cause the console to be opened from within Rails code. (With Better Errors you have to raise an exception.) – Robin Daugherty Jul 30 '17 at 17:12
TL;DR: better_errors is better.
I disagree with the accepted answer here. Mainly because the difference suggested aren't real.
It's always been trivial to trigger a better_errors console anywhere you wanted, as easy as raise 'bang'
. You throw an exception at the point you want and a console gets started in that context. You can raise an exception in any of your files or views and get a console in that context.
I'm not sure if the accepted answer was implying that web_console wouldn't get triggered on an exception and that's why he suggested using both gems, but in any case it's now true that web_console does trigger on exceptions too.
So given there's no functional difference, well, firstly, there's no point running both gems. In fact I'd expect conflicts, though maybe it just comes down to which one catches the exception first.
Secondly, the real difference is that better_errors is just better. Look at screenshots of the two. web_console is just the standard rails exception page with a bare black terminal under it. If you want to know local or instance variables you have to inspect them with the console. better_errors has (to my taste at least) a much prettier styled page, but more importantly it shows the call stack (with compact or full listings), it gives you the code listing where it was triggered just above the console and then below the console it lists request/local/instance variables, which will often explain what the problem is without having to do anything in the console itself. That's a bunch of extra, useful features and nothing missing that web_console has (unless minimalism is your bag).
I don't know why 37Signals/Basecamp or the Rails team decided to incorporate web_console rather than better_errors. Maybe there are design-philosophy/architectural reasons they want to keep it at arms length, maybe they think it's too full featured to be automatically included. Some people seem to think 37Signals strongly prefers stuff built in-house or that can be taken in-house, and maybe that's the only reason why.
Other things that have changed since Thiago posted are that, as marklar says, you now start web_console with console
not debug
and that web_console no longer suggests better_errors as an alternative in its GH README.

- 1,025
- 12
- 17