Thanks for the reply. Frederick Cheung wrote in post #975422: >> klass = class_eval do >> #unsure about this. I need to set table_name to same as class name >> ActiveRecord::Base.set_table_name("#{class_name}") >> ActiveRecord::Base.const_set(constant_name, klass) >> end # class_eval > > This sounds fishy, you're calling set_table_name on AR::Base, not your > class. just klass.set_table_name 'blah' should be enough
True. I receive an unknown method error though. >> eval("#{table_name} = #{class_name}.new") > You haven't created a constant called class_name - > You probably wanted Object.const_set class_name, klass Sorry - I seem to have missed posting the class_name = table_name.camelize line in there (have large sections of comments that I didn't want to clutter the post). I've changed the above code to: APP_TABLES.each do |table_name| class_name = table_name.camelize klass = Class.new(App) constant_name = "#{class_name}" klass = class_eval do set_table_name("#{class_name}") or puts "Class set table name failed" Object.const_set(constant_name, klass) or puts "Class name constant set failed" end # class_eval but get an unknown method error on the set_table_name call. The App class (below) inherits from ActiveRecord::Base which in turn should have that method. class App < ActiveRecord::Base abstract_class = true def initialize establish_connection :app_development end # to avoid trying to connect to the Spydirdb table by default def self.columns() @columns ||= []; end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.