aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/railtie.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/railtie.rb')
-rw-r--r--activesupport/lib/active_support/railtie.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb
index 1f32f8718f..c2deba3b1b 100644
--- a/activesupport/lib/active_support/railtie.rb
+++ b/activesupport/lib/active_support/railtie.rb
@@ -12,6 +12,36 @@ module ActiveSupport
require 'active_support/whiny_nil' if app.config.whiny_nils
end
+ initializer "active_support.deprecation_behavior" do |app|
+ if deprecation = app.config.active_support.deprecation
+ ActiveSupport::Deprecation.behavior = deprecation
+ else
+ defaults = {"development" => :log,
+ "production" => :notify,
+ "test" => :stderr}
+
+ env = Rails.env
+
+ if defaults.key?(env)
+ msg = "You did not specify how you would like Rails to report " \
+ "deprecation notices for your #{env} environment, please " \
+ "set config.active_support.deprecation to :#{defaults[env]} " \
+ "at config/environments/#{env}.rb"
+
+ warn msg
+ ActiveSupport::Deprecation.behavior = defaults[env]
+ else
+ msg = "You did not specify how you would like Rails to report " \
+ "deprecation notices for your #{env} environment, please " \
+ "set config.active_support.deprecation to :log, :notify or " \
+ ":stderr at config/environments/#{env}.rb"
+
+ warn msg
+ ActiveSupport::Deprecation.behavior = :stderr
+ end
+ end
+ end
+
# Sets the default value for Time.zone
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
initializer "active_support.initialize_time_zone" do |app|
@@ -27,4 +57,4 @@ module ActiveSupport
Time.zone_default = zone_default
end
end
-end \ No newline at end of file
+end