I am working on a reporting and registration system that will act as a window for viewing statistics of other applications. I want ORM ActiveRecord functionality, but you do not have application database structures before you start.
Additional databases are defined in database.yml, and then I connect to the class.
class externalapp < ActiveRecord::Base
establish_connection :externalapp_db
end
def create_class(class_name, superclass, &block)
klass = Class.new superclass, &block
Object.const_set class_name, klass
end
I need to be able
- Create classes (from tables) on the fly and
- bind them to external database tables
Am I approaching this wrong? How can I better use namespacing for external databases, allowing the creation of dynamic classes.
Suggestions and help appreciated.
source
share