This is how to convert a string to a class in Rails/Ruby:
p = "Post"
Kernel.const_get(p)
eval(p)
p.constantize
But what if I am retrieving a column from an array/active record object like:
Post.description
but it could be
Post.anything
where anything is a string like anything = "description"
How can I make it work? Any ideas. This is helpful since I want to refactor a very large class and reduce lines of code and repetition.
Many thanks.