meta modeling in ActiveRecord/ Rails

Hi,

I am trying to create a design for user defined tables which could be stored in a database then initialized from a controller as needed. At present I am having a bit of trouble getting these metamodels into the rails env from a controller. Is there a way that I can class_eval a model that would be able to be seen for the duration of that process?

class Admin::UdtManagersController < Admin::Auth #< ApplicationController
before_filter :initialize_meta_environment

def index # rails complains if this isn’t here
end

private

  def initialize_meta_environment
    @table = 'review_processes' #define this hard coded for now... later passed via param
    @model = @table.classify

    init_models


  end

  def init_models
    class_eval= %q{
       class #{@model} < ActiveRecord::Base

       validates_presence_of :summary_reviews
       end
      }

   ## How can I eval this model so it will become part of my application for that process?

  end

end

Any help is totally appreciated! Thanks in advance.

-Mark

Figured this out for nbow… You can do something like…

model_class = create_arec @table do

validates_presence_of :summary_reviews

end

model = Object.const_set(@table.classify, model_class)

def create_arec(table_name, &block)

klass = Class.new(ActiveRecord::Base){self.table_name = table_name}

klass.class_eval &block

klass

end

def create_acntl(controller_name, super_class = ApplicationController, &block)

klass = Class.new(super_class)

klass.class_eval &block

klass

end

def compose_controller(klass, &block)

klass.class_eval &block

end

THis will create the objects… still have not got it doing exactly what I want to.

More later perhaps!

hope this helps someone.

–mark