title: Retrieving Associated Records Dynamically (Tableize)?
body: <p>I am trying to build a <em>generalized</em> function that can retrieve associations of given object. The object is passed, but what associations are to be retrieved needs to be dynamic.</p>
  
  <p>Using a method called <code>associations</code>, I can get an array of models that associate with the given object. My problem is how to take that information and use it to retrieve the rails association (using the standard <code>a = b.models</code>).</p>
  
  <p>I am trying to use <code>tableize</code> but it doesn't work (getting an <code>undefined method error</code>)--it doesn't seem to think of it as a table name.</p>
  
  <p>My code essentially boils down to:</p>
  
  <pre><code> assoc = obj.associations
   tablename = assoc[0].tableize
   obj.tablename.each
  </code></pre>
  
  <p>What is the correct way to do this? </p>