I’m new to Ruby and Rails, too. Chris’ example is very cool - I hadn’t
seen
“Module.const_get” before. A less sophisticated (and much more
dangerous)
way to do the same thing would be to use eval:
x = “Foo”
obj = eval("#{x}.new")
obj.class => Foo
Actually, good Rubyists can manage to construct whole classes (and
modules and definitions)
on the fly, not just objects. Cool stuff.
Jim
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.