class Module alias :normal_const_missing :const_missing def const_missing(class_id) begin return normal_const_missing(class_id) rescue end unless table_name = DrNic::MagicModels::Schema.models[class_id] raise NameError.new("uninitialized constant #{class_id}") if DrNic::MagicModels::Schema.models.enquired? class_id end klass_code = lambda {klass_code} klass = Class.new ActiveRecord::Base, &klass_code const_set class_id, klass end end