Module: Rack::MiniProfilerRails
- Defined in:
- lib/mini_profiler_rails/railtie.rb
Defined Under Namespace
Classes: Railtie
Class Method Summary collapse
-
.initialize!(app) ⇒ Object
call direct if needed to do a defer init.
Class Method Details
.initialize!(app) ⇒ Object
call direct if needed to do a defer init
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mini_profiler_rails/railtie.rb', line 6 def self.initialize!(app) c = Rack::MiniProfiler.config # By default, only show the MiniProfiler in development mode, in production allow profiling if post_authorize_cb is set c. ||= lambda { |env| !Rails.env.test? } c.skip_paths ||= [] if Rails.env.development? c.skip_paths << app.config.assets.prefix c.skip_schema_queries = true end if Rails.env.production? c. = :whitelist end if Rails.logger c.logger = Rails.logger end # The file store is just so much less flaky tmp = Rails.root.to_s + "/tmp/miniprofiler" FileUtils.mkdir_p(tmp) unless File.exists?(tmp) c. = {:path => tmp} c.storage = Rack::MiniProfiler::FileStore # Quiet the SQL stack traces c.backtrace_remove = Rails.root.to_s + "/" c.backtrace_includes = [/^\/?(app|config|lib|test)/] c.skip_schema_queries = Rails.env != 'production' # Install the Middleware app.middleware.insert(0, Rack::MiniProfiler) # Attach to various Rails methods ::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"} ::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"} end |