3

I must to enable rack-mini-profiler for dev and production. In ApplicationController I have:

before_filter :miniprofiler

def miniprofiler
  Rack::MiniProfiler.authorize_request #if current_user.admin?
end

In config/initializers/rack_profiler.rb

if Rails.env == 'development'
  require 'rack-mini-profiler'

  Rack::MiniProfilerRails.initialize!(Rails.application)
end

In dev environment all works fine, but when i push to staging on Heroku, server falls with the

NameError (uninitialized constant Rack::MiniProfiler)

in this line

Rack::MiniProfiler.authorize_request #if current_user.admin?

I tried add

reqire 'rack-mini-profiler' to ApplicationController

but then I cann't even push it to staging with

Push rejected, failed to compile Multipack app

What i am missing?

2 Answers2

3

If the rack-mini-profiler gem is in the :development group in your Gemfile, then it is simply not installed on your staging server.

Yury Lebedev
  • 3,985
  • 19
  • 26
1

Hi NOTE: Be sure to require the rack_mini_profiler gem below the pg and mysql gems in your Gemfile. rack_mini_profiler will identify these gems if they are loaded to insert instrumentation

And you don't really need the require line this method

if Rails.env == 'development'
 require 'rack-mini-profiler' //THIS LINE
 Rack::MiniProfilerRails.initialize!(Rails.application)
end
Thabo
  • 1,303
  • 2
  • 19
  • 40