SamSaffron / MiniProfiler

A simple but effective mini-profiler for ASP.NET MVC, ASP.NET and Ruby.
http://miniprofiler.com
1.05k stars 221 forks source link

Doesnt Seem to be working with Mountable Rails engines #178

Open shshankjain opened 11 years ago

shshankjain commented 11 years ago

I am able to get it working in the development environment with basic pages (root level). But when I navigate inside a Rails (mountable) engine, I stop seeing miniprofiler data.

The moment I go back to application root, I can see multiple miniprofiler badges with data.

Changing the below in https://github.com/SamSaffron/MiniProfiler/blob/master/Ruby/lib/mini_profiler/profiler.rb#L509

    def get_profile_script(env)
      ids = ids_comma_separated(env)
      path = "#{env['SCRIPT_NAME']}#{@config.base_url_path}"

to

    def get_profile_script(env)
      ids = ids_comma_separated(env)
      # Could be done better for applications which are deployed under non root context
      path = "#{@config.base_url_path}"

Fixes the issue.

Note : Using rails (3.2.12)

SamSaffron commented 11 years ago

Will this break subdirectroy based rails installs though? care to give a full fix a shot, I don't really want to fix this just to break other cases.

mozcomp commented 11 years ago

This was a major headache for me using a plethora of mountable engines. Thanks for finding a little fix - even if it has caused some more breaks elsewhere? I haven't seen any problems yet.

mjc commented 10 years ago

@SamSaffron looks like rails4 mangles the SCRIPT_NAME based on the engine's mounted location so it's not an accurate method of getting the base.

https://github.com/rails/rails/commit/5b3bb61f3fb82c7300d4dac374fe7aeafff6bda0

Perhaps it would be ideal to append env['SCRIPT_NAME'] to the default base_url_path instead of appending it to all base_url_paths, so that if people need to override it, they can do so without patching miniprofiler?

SamSaffron commented 10 years ago

sure, care to try a PR for it?

On Thu, Sep 12, 2013 at 6:59 AM, Michael J. Cohen notifications@github.comwrote:

@SamSaffron https://github.com/SamSaffron looks like rails4 mangles the SCRIPT_NAME based on the engine's mounted location so it's not an accurate method of getting the base.

rails/rails@5b3bb61https://github.com/rails/rails/commit/5b3bb61f3fb82c7300d4dac374fe7aeafff6bda0

Perhaps it would be ideal to append env['SCRIPT_NAME'] to the default base_url_path instead of appending it to all base_url_paths, so that if people need to override it, they can do so without patching miniprofiler?

— Reply to this email directly or view it on GitHubhttps://github.com/SamSaffron/MiniProfiler/issues/178#issuecomment-24275889 .