Permalink
Browse files

Remove defined?(ActiveRecord) and use the railtie hook instead.

  • Loading branch information...
josevalim committed May 4, 2011
1 parent cea3b3c commit b9bba555caa95389e97bd7d32472ddc1e429d7c2
Showing with 4 additions and 7 deletions.
  1. +4 −3 activerecord/lib/active_record/railtie.rb
  2. +0 −4 railties/lib/rails/commands/console.rb
@@ -26,10 +26,11 @@ class Railtie < Rails::Railtie
load "active_record/railties/databases.rake"
end
- # When loading console, force ActiveRecord to be loaded to avoid cross
- # references when loading a constant for the first time.
+ # When loading console, force ActiveRecord::Base to be loaded
+ # to avoid cross references when loading a constant for the
+ # first time. Also, make it output to STDERR.
console do
- ActiveRecord::Base
+ ActiveRecord::Base.logger = Logger.new(STDERR)
end
initializer "active_record.initialize_timezone" do
@@ -34,10 +34,6 @@ def start
exit
end
end
-
- if defined?(ActiveRecord)
- ActiveRecord::Base.logger = Logger.new(STDERR)
- end
if options[:sandbox]
puts "Loading #{Rails.env} environment in sandbox (Rails #{Rails.version})"

1 comment on commit b9bba55

maia commented on b9bba55 Sep 17, 2011

I wish there was a way to disable the logging to STDERR other than placing

ActiveRecord::Base.logger = Logger.new(Rails.root.join('log', 'development.log')) if defined?(ActiveRecord)

in ~/.ircrc, wouldn't an option like config.active_record.console_logging = false make sense?

Please sign in to comment.