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