MiniProfiler icon indicating copy to clipboard operation
MiniProfiler copied to clipboard

Doesnt Seem to be working with Mountable Rails engines

Open shshankjain opened this issue 11 years ago • 4 comments

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)

shshankjain avatar Jul 24 '13 08:07 shshankjain

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.

SamSaffron avatar Jul 30 '13 01:07 SamSaffron

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.

mozcomp avatar Aug 01 '13 00:08 mozcomp

@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?

mjc avatar Sep 11 '13 20:09 mjc

sure, care to try a PR for it?

On Thu, Sep 12, 2013 at 6:59 AM, Michael J. Cohen [email protected]:

@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 .

SamSaffron avatar Sep 11 '13 23:09 SamSaffron