ruby convert class name in string to actual class

How do I call a class from a string containing that class name inside of it? (I guess I could do case/when but that seems ugly.)

The reason I ask is because I'm using the acts_as_commentable plugin, among others, and these store the commentable_type as a column. I want to be able to call whatever particular commentable class to do a find(commentable_id) on it.

Thanks.


I think what you want is constantize

That's an RoR construct. I don't know if there's one for ruby core


"Object".constantize # => Object