# Railties is inserting MiniProfiler too late in the chain

**URL:** <https://community.miniprofiler.com/t/railties-is-inserting-miniprofiler-too-late-in-the-chain/163>\
**Category:** uncategorized\
**Created:** [April 26, 2012, 9:03pm UTC](https://community.miniprofiler.com/t/railties-is-inserting-miniprofiler-too-late-in-the-chain/163 "2012-04-26T21:03:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam](https://sea2.discourse-cdn.com/flex016/user_avatar/community.miniprofiler.com/sam/32/377_2.png) [@sam](https://community.miniprofiler.com/u/sam)\
**Post date:** [April 26, 2012, 9:03pm UTC](https://community.miniprofiler.com/t/railties-is-inserting-miniprofiler-too-late-in-the-chain/163/1 "2012-04-26T21:03:20Z")

</div>

For my app railsties is inserting MiniProfiler way too late in the chain:

Here is my output for `rake middleware`

```
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0xb7c7bac>
use Rack::Runtime
use Rack::MethodOverride
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::RemoteIp
use Rack::Sendfile
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
use Sass::Plugin::Rack
use Rack::MiniProfiler
run MyBlog::Application.routes

```

MiniProfiler should be as early as possible so it can profile the various rack filters as well.

---

<div class="post-metadata">

**Author:** ![Evil\_Trout](https://sea2.discourse-cdn.com/flex016/user_avatar/community.miniprofiler.com/evil_trout/32/1045_2.png) [@Evil\_Trout](https://community.miniprofiler.com/u/Evil_Trout)\
**Post date:** [May 3, 2012, 5:23am UTC](https://community.miniprofiler.com/t/railties-is-inserting-miniprofiler-too-late-in-the-chain/163/2 "2012-05-03T05:23:29Z")

</div>

I was able to insert the instrumentation earlier, see commit: c455ab1

I tried to move it higher but it stopped showing up on AJAX requests and such, presumably due to rack dependencies that were required.
