Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make RAILS_* give deprecation warning just once

  • Loading branch information...
commit 25b6b95459ae71218754e8469f77f86b676bf215 1 parent 06860dc
Pratik lifo authored
Showing with 21 additions and 6 deletions.
  1. +21 −6 railties/lib/rails/deprecation.rb
27 railties/lib/rails/deprecation.rb
View
@@ -2,6 +2,9 @@
require "active_support/deprecation"
RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
+ cattr_accessor :warned
+ self.warned = false
+
def target
Rails.root
end
@@ -11,12 +14,17 @@ def replace(*args)
end
def warn(callstack, called, args)
- msg = "RAILS_ROOT is deprecated! Use Rails.root instead"
- ActiveSupport::Deprecation.warn(msg, callstack)
+ unless warned
+ ActiveSupport::Deprecation.warn("RAILS_ROOT is deprecated! Use Rails.root instead", callstack)
+ self.warned = true
+ end
end
end).new
RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
+ cattr_accessor :warned
+ self.warned = false
+
def target
Rails.env
end
@@ -26,12 +34,17 @@ def replace(*args)
end
def warn(callstack, called, args)
- msg = "RAILS_ENV is deprecated! Use Rails.env instead"
- ActiveSupport::Deprecation.warn(msg, callstack)
+ unless warned
+ ActiveSupport::Deprecation.warn("RAILS_ENV is deprecated! Use Rails.env instead", callstack)
+ self.warned = true
+ end
end
end).new
RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
+ cattr_accessor :warned
+ self.warned = false
+
def target
Rails.logger
end
@@ -41,7 +54,9 @@ def replace(*args)
end
def warn(callstack, called, args)
- msg = "RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead"
- ActiveSupport::Deprecation.warn(msg, callstack)
+ unless warned
+ ActiveSupport::Deprecation.warn("RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead", callstack)
+ self.warned = true
+ end
end
end).new
Please sign in to comment.
Something went wrong with that request. Please try again.