Enrique Comba Riepenhausen
6/15/2007 2:42:00 PM
Hi Peer,
On Friday, June 15, 2007, at 04:36PM, "Peer Allan" <peer@canadadrugs.com> wrote:
>Hi all,
>I know this can be done, but I can't find out how to do it. I have a
>string with the name of the class that I want to initialize, but how do
>I do it?
>
>This is what I tried,
>
>class = "Product"
>product = class.new
>
>Obviously this does not work or I wouldn't be asking :) So, how do I do
>this?
>
>Peer
Try this:
clazz = Object.const_get("Product")
product = clazz.new
The word class is a reserved word so yu should use something different...
Cheers,
Enrique