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 On Friday, October 30, 2015 at 12:14:12 PM UTC-4, mark wrote: > > 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 > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3b04bec0-f962-4ae5-989c-28662cdf2956%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.