Rack-mini-profiler missing?

If you’re trying to install rack-mini-profiler and it’s missing in production, the likely cause is the order of your middleware.

Docs: https://github.com/MiniProfiler/rack-mini-profiler

Run this command

RAILS_ENV=production rake middleware

And then double check that that the Rack::MinProfiler is after any “deflating” middlewares.

This worked for me:

# CRITICAL TO DO THIS REQUIRE
require 'rack-mini-profiler'

# CRITICAL that we load MiniProfiler after the Deflators
# See https://github.com/MiniProfiler/rack-mini-profiler/issues/134#issuecomment-126648241
if Rails.env.production? or Rails.env.staging?
  Rails.application.middleware.delete(Rack::MiniProfiler)
  Rails.application.middleware.insert_after(HerokuDeflater::SkipBinary, Rack::MiniProfiler)
end

Here are a few related issues. This is a yak shave for many:

The tool is good enough and popular enough that I deem this effort a worthwhile, albeit a painful, endeavor!