Ruby on Rails
Friday, October 30, 2015
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
-- 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+unsubscribe@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/d78fcd66-0caa-4414-b2ca-f01b4a333588%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment