Better Errors in Padrino

The development and debugging cycle is much more efficient when developing in Padrino when the addition of better_errors. The provided documentation won’t get better_errors working for you with the installation snippets.

To get the most out of better_errors, two additional items must be added to the Gemfile. I put them in a development group, but you don’t have to.

# Gemfile
group :development do
  gem "better_errors"
  gem "binding_of_caller"

In config/boot.rb, require better_errors and set up the Rack middleware.

# config/boot.rb, after Bundler.require(:default, RACK_ENV)
if Padrino.env == :development
  require 'better_errors'
  Padrino::Application.use BetterErrors::Middleware
  BetterErrors.application_root = PADRINO_ROOT
  BetterErrors.logger = Padrino.logger

For better_errors to work properly, cross-Site Request Forgery protection must be disabled environment.

# config/apps.rb
set :protect_from_csrf, !(Padrino.env == :development)