Skip to content
Browse files

Fix up AR extension by using Railties module instead of Rails and req…

…uiring ControllerRuntime at initialization time instead of boot
  • Loading branch information...
1 parent d349b22 commit 10a2638db099baddfa46da98f780df3a72a718d4 @jeremy jeremy committed Dec 30, 2009
View
1 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
View
15 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 @@ class Plugin < Rails::Plugin
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 @@ class Plugin < Rails::Plugin
# 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 @@ class Plugin < Rails::Plugin
end
end
-end
+end
View
2 ...active_record/rails/controller_runtime.rb → ...ive_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
View
0 ...rd/lib/active_record/rails/databases.rake → ...lib/active_record/railties/databases.rake
File renamed without changes.

0 comments on commit 10a2638

Please sign in to comment.
Something went wrong with that request. Please try again.