Need help: Nothing is inserted into the DOM

Hi,

thanks for this awesome project! I’ve successfully used it before but ran into issues with a specific rails app recently:

  1. My rails version is 4.2.7.1.
  2. The rack-mini-profiler version is 0.10.2.
  3. The rails environment is development.
  4. Neither the div.profiler-results nor the script#profilerTemplate are inserted into the DOM. (It works with a fresh rails app.)
  5. No javascript errors. In fact, removing all javascripts does not help.
  6. The tmp/miniprofiler directory does not show up at first, but appears a couple of minutes later, which puzzles me.
  7. Rack::MiniProfiler is the first entry of rake middleware.
  8. http://localhost:3000?pp=help does work.

Could anyone give me a hint how rack-mini-profiler inserts the div and the script tag? Maybe from there, I can debug why those are missing.

Thanks!

It happens here:

what you could do is source it from local in your gemfile eg:

gem 'rack-mini-profiler', path: '../rack-mini-profiler'

and then add puts statements to see where it is stopping in the sequence.

But first things first, do you see it in rake middleware ?

Thanks for your quick reply, @sam!

Yes, I do:

➜  bundle exec rake middleware
I, [2017-02-24T13:52:50.031553 #42778]  INFO -- : Celluloid 0.17.3 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
[Simple Form] Simple Form is not configured in the application and will use the default values. Use `rails generate simple_form:install` to generate the Simple Form configuration.
use Rack::MiniProfiler
use Rack::Sendfile
use ActionDispatch::Static
use Rack::Lock
use Rack::Timeout
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use MetaRequest::Middlewares::Headers
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::Migration::CheckPending
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Warden::Manager
use MetaRequest::Middlewares::MetaRequestHandler
use MetaRequest::Middlewares::AppRequestHandler
use OmniAuth::Builder
use ExceptionNotification::Rack
use RedisAnalytics::Tracker
use Rack::Turnout
run MyApplication::Application.routes

Anything looking unusual here?

I’ve added a debug output in

    # inject headers, script
    if status >= 200 && status < 300
      result = inject_profiler(env,status,headers,body)
      p "=== MINI PROFILER === 344 status #{status}"
      p result
      p "======="
      return client_settings.handle_cookie(result) if result
    end

I do see some outputs, but result appears to be nil:

"=== MINI PROFILER === 344 status 200"
nil
"======="

And, while grepping for this output, I’ve found something else:

MiniProfiler storage failure: private method url_for called for #<PagesController:0x007fb6cef9f2e0>,

which is called here:

Ok, I’ve found it:

Indeed, I’ve overridden url_for in my ApplicationController as I need slightly different behaviour for permalinks in this application.

I thought that, in controllers, action methods should be public, other methods private. But defining the url_for override as public solves my issue.

Thanks for your help!

1 Like