From: Rick DeNatale Date: 2010-12-04T02:01:08+09:00 Subject: Re: cast object to object On Fri, Dec 3, 2010 at 11:35 AM, Robert Klemme wrote: > >> name_of_my_class.to_class  # Create a class out of the user input > > That sounds more like it. > > David, you could do > > class_name = ... # fetch the name from somewhere > dave = Object.const_get(class_name).new Or for a more robust solution which can also handle strings like "Module::Class" have a look at the String#constantize method from activesupport (part of Rails) -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale