Using dynamically created classes in a Single Table Inheritance mechanism
问题 I have an ActiveRecord class called 'DynObject' which can be used for inheritance.. On initialization I dynamically create some Classes that inherit from it: classes_config = { foo: 'foo', bar: 'bar' } classes_config.each do |name,options| klass = Class.new( DynObject ) do end self.klasses[name] = const_set( "#{name.camelize}DynObject", klass ) end This is all good, these classes are created just fine.. But when ActiveRecord tries to load created records the STI mechanism failes..