ActionController::Dispatcher#cleanup_application does this:
def cleanup_application(force = false)
if Dependencies.load? || force
ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
Dependencies.clear
ActiveRecord::Base.clear_reloadable_connections! if
defined?(ActiveRecord)
end
end
where
def self.reset_subclasses #:nodoc:
nonreloadables =
subclasses.each do |klass|
unless Dependencies.autoloaded? klass
nonreloadables << klass
next
end
klass.instance_variables.each { |var|
klass.send(:remove_instance_variable, var) }
klass.instance_methods(false).each { |m| klass.send :undef_method, m }
end
@@subclasses = {}
nonreloadables.each { |klass| (@@subclasses[klass.superclass]
Probably because they have to reload the database schema
which is partly described in their class instance variables
on every request.
For example, columns:
# Returns an array of column objects for the table associated with
this class.
def columns
unless @columns@columns = connection.columns(table_name, "#{name} Columns")
@columns.each {|column| column.primary = column.name ==
primary_key}
end
@columns
end
But if the class was autoloaded wouldn't that be a side-effect of
remove_const Model + const_missing Model as with the rest of
autoloaded classes? Why are those special removals needed?
But if the class was autoloaded wouldn't that be a side-effect of
remove_const Model + const_missing Model as with the rest of
autoloaded classes? Why are those special removals needed?
Indeed that does seem unneeded at first glance. Another thing to test
out once 2.0 is out the door I guess