diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-12-30 19:24:00 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-12-30 19:24:00 -0800 |
commit | 10a2638db099baddfa46da98f780df3a72a718d4 (patch) | |
tree | 88aefafe390842efe1f31fb9602af2eda90433b4 /activerecord | |
parent | d349b22097e6b50a9593ba5ba4c028070688342a (diff) | |
download | rails-10a2638db099baddfa46da98f780df3a72a718d4.tar.gz rails-10a2638db099baddfa46da98f780df3a72a718d4.tar.bz2 rails-10a2638db099baddfa46da98f780df3a72a718d4.zip |
Fix up AR extension by using Railties module instead of Rails and requiring ControllerRuntime at initialization time instead of boot
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/rails.rb | 15 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/controller_runtime.rb (renamed from activerecord/lib/active_record/rails/controller_runtime.rb) | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake (renamed from activerecord/lib/active_record/rails/databases.rake) | 0 |
4 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index 87de480263..a524dc50a1 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -60,7 +60,6 @@ module ActiveRecord autoload :Batches autoload :Calculations autoload :Callbacks - autoload :ControllerRuntime autoload :DynamicFinderMatch autoload :DynamicScopeMatch autoload :Migration diff --git a/activerecord/lib/active_record/rails.rb b/activerecord/lib/active_record/rails.rb index 69f38e75c8..8bc49c3d96 100644 --- a/activerecord/lib/active_record/rails.rb +++ b/activerecord/lib/active_record/rails.rb @@ -3,17 +3,14 @@ # here. This is needed for correctly setting up the middleware. # In the future, this might become an optional require. require "action_controller/rails" -require "active_record/rails/controller_runtime" module ActiveRecord class Plugin < Rails::Plugin plugin_name :active_record include_modules_in "ActiveRecord::Base" - config.action_controller.include "ActiveRecord::Rails::ControllerRuntime" - rake_tasks do - load "active_record/rails/databases.rake" + load "active_record/railties/databases.rake" end initializer "active_record.set_configs" do |app| @@ -34,6 +31,12 @@ module ActiveRecord ActiveRecord::Base.default_timezone = :utc end + # Expose database runtime to controller for logging. + initializer "active_record.log_runtime" do |app| + require "active_record/railties/controller_runtime" + ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime + end + # Setup database middleware after initializers have run initializer "active_record.initialize_database_middleware" do |app| middleware = app.config.middleware @@ -52,7 +55,7 @@ module ActiveRecord # TODO: ActiveRecord::Base.logger should delegate to its own config.logger initializer "active_record.logger" do - ActiveRecord::Base.logger ||= Rails.logger + ActiveRecord::Base.logger ||= ::Rails.logger end initializer "active_record.notifications" do @@ -64,4 +67,4 @@ module ActiveRecord end end -end
\ No newline at end of file +end diff --git a/activerecord/lib/active_record/rails/controller_runtime.rb b/activerecord/lib/active_record/railties/controller_runtime.rb index b8d5a77a0d..535e967ec3 100644 --- a/activerecord/lib/active_record/rails/controller_runtime.rb +++ b/activerecord/lib/active_record/railties/controller_runtime.rb @@ -1,7 +1,7 @@ require 'active_support/core_ext/module/attr_internal' module ActiveRecord - module Rails + module Railties module ControllerRuntime extend ActiveSupport::Concern diff --git a/activerecord/lib/active_record/rails/databases.rake b/activerecord/lib/active_record/railties/databases.rake index a35a6c156b..a35a6c156b 100644 --- a/activerecord/lib/active_record/rails/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake |