[RoR],[C.L.R] How I convert an AR-Class-name to a symbol?

People,

I’m looking for a method to convert an AR-Class-name to a symbol.

Something like this:

AppServerType.class_name_to_symbol => :app_server_type

Also I’m looking for this:

:app_server_type.symbol_to_class_name => “AppServerType”

I’m sure this code sits in rails somewhere.

I can see evidence of its use all over the place but I’m not tuned-in enough to find it.

I tried to find some clues here:

http://api.rubyonrails.org

But, I see too much info there.

-Peter

I tried to find some clues here:

http://api.rubyonrails.org

This is a good place to look too: http://www.ruby-doc.org/core/

Take a look at the to_sym method for the String class and the to_s method for the Symbol class.

"hello".to_sym => :hello :hello.to_s => "hello"

Aaron

MyModel.name.underscore.to_sym => :my_model

:my_model.to_s.camelize.constantize => MyModel

Thanks!

Now I’m curious about how to change: “AppServer” to “app_server”

-Peter

Hi there..

"AppServer".tableize

#=> "app_servers"

close enough.. ?

jason.