From: Victor Shepelev Date: 2006-05-31T09:04:18+09:00 Subject: Re: class from string From: list-bounce@example.com [mailto:list-bounce@example.com] On Behalf Of Dan Kirkwood Sent: Wednesday, May 31, 2006 2:53 AM > Is there a better way to get to a class when you have the class name in > a string? > (This is rails-related, btw).. For instance, if I have a string clname > = 'Train', and I want to access a class method Train#label. I can do > this: > > clname = 'Train' > label = eval "#{clname}.label" > > Is there a better way? Aha. clname = 'Train' label = Object.const_get(clname).new p label.class #=> Train V.