Sometimes it is necessary to override inbuilt functionality of Rails (or other dependencies) by creating a monkey patch. However this may only be intended as a temporary solution, waiting on some future fix or upgrade to the framework.

In that case, it would be helpful to create a warning that will remind team members to remove the override later.


# config/initializers/special_tableize.rb

module ActiveSupport
  module Inflector
    def tableize(class_name)
      base_name = pluralize(underscore(class_name))

      "special_" + base_name

if Rails.version =~ /^6\.2/
  warn "Rails is now at 6.2, special tableize() may be removed"

In this (very contrived) example, ActiveSupport::Inflector’s tableize method has been overridden, pending a future framework change. A warning has been added that will keep a reminder of the change visible, without interrupting normal operation.