lib/mini_profiler_rails/railtie.rb in rack-mini-profiler-0.9.1 vs lib/mini_profiler_rails/railtie.rb in rack-mini-profiler-0.9.2

- old
+ new

@@ -2,10 +2,13 @@ module Rack::MiniProfilerRails # call direct if needed to do a defer init def self.initialize!(app) + + raise "MiniProfilerRails initialized twice. Set `require: false' for rack-mini-profiler in your Gemfile" if @already_initialized + c = Rack::MiniProfiler.config # By default, only show the MiniProfiler in development mode, in production allow profiling if post_authorize_cb is set # # NOTE: this must be set here with = and not ||= @@ -19,11 +22,11 @@ if Rails.env.development? c.skip_paths << app.config.assets.prefix if app.respond_to? :assets c.skip_schema_queries = true end - if Rails.env.production? + unless Rails.env.development? || Rails.env.test? c.authorization_mode = :whitelist end if Rails.logger c.logger = Rails.logger @@ -38,11 +41,11 @@ 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' + c.skip_schema_queries = (Rails.env.development? || Rails.env.test?) # Install the Middleware app.middleware.insert(0, Rack::MiniProfiler) # Attach to various Rails methods @@ -50,9 +53,11 @@ ::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"} end ActiveSupport.on_load(:action_view) do ::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"} end + + @already_initialized = true end class Railtie < ::Rails::Railtie initializer "rack_mini_profiler.configure_rails_initialization" do |app|