Skip to Content Skip to Search

Deprecation specifies the API used by Rails to deprecate methods, instance variables, objects, and constants.

Included Modules


DEFAULT_BEHAVIORS = { raise: ->(message, callstack, deprecation_horizon, gem_name) { e = e.set_backtrace( raise e }, stderr: ->(message, callstack, deprecation_horizon, gem_name) { $stderr.puts(message) $stderr.puts callstack.join("\n ") if debug }, log: ->(message, callstack, deprecation_horizon, gem_name) { logger = if defined?(Rails.logger) && Rails.logger Rails.logger else require "active_support/logger"$stderr) end logger.warn message logger.debug callstack.join("\n ") if debug }, notify: ->(message, callstack, deprecation_horizon, gem_name) { notification_name = "deprecation.#{'/', '_')}" ActiveSupport::Notifications.instrument(notification_name, message: message, callstack: callstack, gem_name: gem_name, deprecation_horizon: deprecation_horizon) }, silence: ->(message, callstack, deprecation_horizon, gem_name) { }, }

Default warning behaviors per Rails.env.


[RW] deprecation_horizon

The version number in which the deprecated behavior will be removed, by default.

Class Public methods

new(deprecation_horizon = "7.1", gem_name = "Rails")

It accepts two parameters on initialization. The first is a version of library and the second is a library name.'2.0', 'MyLibrary')
# File activesupport/lib/active_support/deprecation.rb, line 41
def initialize(deprecation_horizon = "7.1", gem_name = "Rails")
  self.gem_name = gem_name
  self.deprecation_horizon = deprecation_horizon
  # By default, warnings are not silenced and debugging is off.
  self.silenced = false
  self.debug = false
  @silenced_thread =
  @explicitly_allowed_warnings =