Things Learnt Running Disqus Locally and Better Errors

I decided to start swapping out the CSS styles and layout for this site with CSS Grid. At the time of this writing, the site uses Skeleton for styles and layout. Skeleton is pretty good, but I just want to experiment with CSS Grid and different modular scales for type. So I fired up the Middleman app locally and got an undefined local variable or method 'disqus' error in the browser window. It was just the no frills error message, so I thought that I'd like some more informative errors before I tackled running Disqus locally in my Rails app.

Specific Examples

One of the key things to do is to only run Better Errors in development. Add this to your Gemfile:

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

The second thing that I learned was that you have to explicitly remove the Rack::ShowExceptions middleware. Add this to your config.rb:

# Better Errors configuration
set :show_exceptions, false # Disable Rack::ShowExceptions middleware

require 'better_errors' # Do not forget to load the gem
configure :development do
  use BetterErrors::Middleware
  BetterErrors.application_root = __dir__

The third thing that I learned is similar to the first and deals with Disqus in development. Only include Disqus in builds, not when running middleman server. Add this to your config.rb:

# Development-specific configuration
configure :development do
  activate :disqus do |d|
    # or setting to `nil` will stop Disqus loading
    d.shortname = nil

Lastly, Middleman app reloads all of the dependencies and breaks Better Errors. You do at least get files and line numbers in the output. I'll look around for a solution.