G
Glenn
[Note: parts of this message were removed to make it a legal post.]
Hi,
I want to create a class and define a subclass of ActiveRecord within that class, like this:
class Results
def initialize(db)
class db < ActiveRecord::Base
end
end
end
r1 = Results.new('DM')
r2 = Results.new('AE')
Then I want to put that class definition into an object and use it in the instance methods of the Results class. (The instance methods of the Results class will do stuff with database tables, but I want to pick which table when I create the instances of the Results class.)
I am sure that the syntax above is wrong -- probably in many ways -- but am unsure how to fix it. Ruby does not seem to want to allow class definitions within methods, but if I can't do that, I do not know of another way to do this.
Thanks for your help.
Hi,
I want to create a class and define a subclass of ActiveRecord within that class, like this:
class Results
def initialize(db)
class db < ActiveRecord::Base
end
end
end
r1 = Results.new('DM')
r2 = Results.new('AE')
Then I want to put that class definition into an object and use it in the instance methods of the Results class. (The instance methods of the Results class will do stuff with database tables, but I want to pick which table when I create the instances of the Results class.)
I am sure that the syntax above is wrong -- probably in many ways -- but am unsure how to fix it. Ruby does not seem to want to allow class definitions within methods, but if I can't do that, I do not know of another way to do this.
Thanks for your help.