Permalink
Browse files

Call QueryReviewer.load_configuration later on Rails 3

  • Loading branch information...
1 parent 726684e commit 1888349c88587336ae202c7d3eefabd11d5b4298 @be9 be9 committed Mar 7, 2011
Showing with 17 additions and 17 deletions.
  1. +12 −16 lib/query_reviewer.rb
  2. +5 −1 lib/query_reviewer/rails.rb
View
@@ -12,9 +12,9 @@ def self.load_configuration
CONFIGURATION.merge!(default_config["all"] || {})
CONFIGURATION.merge!(default_config[Rails.env || "test"] || {})
- app_config_file = File.join(Rails.root.to_s, "config", "query_reviewer.yml")
+ app_config_file = Rails.root + "config/query_reviewer.yml"
- if File.exist?(app_config_file)
+ if app_config_file.exist?
app_config = YAML.load(ERB.new(IO.read(app_config_file)).result)
CONFIGURATION.merge!(app_config["all"] || {})
CONFIGURATION.merge!(app_config[Rails.env || "test"] || {})
@@ -29,6 +29,15 @@ def self.load_configuration
rescue
CONFIGURATION["uv"] ||= false
end
+
+ require "query_reviewer/query_warning"
+ require "query_reviewer/array_extensions"
+ require "query_reviewer/sql_query"
+ require "query_reviewer/mysql_analyzer"
+ require "query_reviewer/sql_sub_query"
+ require "query_reviewer/mysql_adapter_extensions"
+ require "query_reviewer/controller_extensions"
+ require "query_reviewer/sql_query_collection"
end
end
@@ -37,18 +46,5 @@ def self.enabled?
end
end
-QueryReviewer.load_configuration
-
-if QueryReviewer.enabled?
- require "query_reviewer/query_warning"
- require "query_reviewer/array_extensions"
- require "query_reviewer/sql_query"
- require "query_reviewer/mysql_analyzer"
- require "query_reviewer/sql_sub_query"
- require "query_reviewer/mysql_adapter_extensions"
- require "query_reviewer/controller_extensions"
- require "query_reviewer/sql_query_collection"
-end
-
# Rails Integration
-require 'query_reviewer/rails' if defined?(Rails)
+require 'query_reviewer/rails' if defined?(Rails)
@@ -24,10 +24,14 @@ class Railtie < Rails::Railtie
end
initializer "query_reviewer.initialize" do
+ QueryReviewer.load_configuration
+
QueryReviewer.inject_reviewer if QueryReviewer.enabled?
end
end
end
else # Rails 2
+ QueryReviewer.load_configuration
+
QueryReviewer.inject_reviewer
-end
+end

0 comments on commit 1888349

Please sign in to comment.