------ art_27632_21087394.1149063314128
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
http://www.eachmapinject.com/class_name.html
j`ey
http://www.eachmapinject.com <http://www.eachmapinject.com/class_name.html>
$_ {$_ {Q};sub(/Q/,$_);print};sub(/Q/,$_);print
On 5/31/06, Ezra Zygmuntowicz <ezmobius / gmail.com> wrote:
>
>
> On May 30, 2006, at 4:52 PM, Dan Kirkwood wrote:
>
> > 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 val "#{clname}.label"
> >
> > Is there a better way?
> >
> > --
> > Posted via http://www.ruby-forum.com/.
> >
>
> In rails you can use #constantize
>
> clname Train'
> clname.constantize.label
>
> But you really should try to search before posting. This was asked a
> bunch of times in the last few weeks.
>
> Cheers-
> -Ezra
>
>
------ art_27632_21087394.1149063314128--