ActiveSupport 3 inflections used standalone

D

Don French

I have some working non rails standalone ruby code under ruby 1.8.6
using activesupport 2.3.5 to take a string and make it into a class
name. I was doing this:

require "active_support"
classes = []
classes << "health_report".classify.constantize

Now under ruby 1.9.2 and rails beta4 it fails. classify is not valid
and I am not sure of constantize. Is there a new way to take a name
of a file and make it into a class name so it can be used. I have a
list of ruby files that contain an individual class. I can require the
file but I do not know the name of the class. I was using the file
basename classified and constantized to create the class name that I
later can use.

Don French
 
X

Xavier Noria

I have some working non rails standalone ruby code under ruby 1.8.6
using activesupport 2.3.5 to take a string and make it into a class
name. I was doing this:

require "active_support"
classes =3D []
classes << "health_report".classify.constantize

Now under ruby 1.9.2 and rails beta4 it fails. classify is not valid
and I am not sure of constantize. =C2=A0Is there a new way to take a name
of a file and make it into a class name so it can be used. =C2=A0I have a
list of ruby files that contain an individual class. I can require the
file but I do not know the name of the class. I was using the file
basename classified and constantized to create the class name that I
later can use.

Active Support now extends practically nothing by default (so it is
less heavyweight by default).

This is a guide about AS core extensions I am writing myself (work in
progress, due for Rails 3):

http://edgeguides.rubyonrails.org/active_support_core_extensions.html#h=
ow-to-load-core-extensions

That particular section explains how to import stuff, there are several opt=
ions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top