diff --git a/activesupport/lib/dependencies.rb b/activesupport/lib/dependencies.rb index 3ceec71873..e5e806b65a 100644 --- a/activesupport/lib/dependencies.rb +++ b/activesupport/lib/dependencies.rb @@ -35,6 +35,10 @@ module Dependencies def require_or_load(file_name) load? ? load("#{file_name}.rb") : require(file_name) end + + def remove_subclasses_for(*classes) + classes.each { |klass| klass.remove_subclasses } + end end Object.send(:define_method, :require_or_load) { |file_name| Dependencies.require_or_load(file_name) } unless Object.respond_to?(:require_or_load) diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index 84dff75024..566b031295 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -49,9 +49,7 @@ class Dispatcher private def reset_application Dependencies.clear - ActiveRecord::Base.remove_subclasses - ActiveRecord::Observer.remove_subclasses - ActionController::Base.remove_subclasses + Dependencies.remove_subclasses_for(ActiveRecord::Base, ActiveRecord::Observer, ActionController::Base) end def controller_path(controller_name, module_name = nil)