title: Find the associations for an ActiveRecord class at run-time?
body: <p>I would like to find the assocations of an ActiveRecord class at runtime...</p>
  
  <p>Let's assume I have the following:</p>
  
  <pre><code>class Person &lt; ActiveRecord::Base
    has_many :chairs
    has_many :pens
  end
  
  class Chair &lt; ActiveRecord::Base
    belongs_to :person
  end
  
  class Pen &lt; ActiveRecord::Base
    belongs_to :person
  end
  </code></pre>
  
  <p>How can I find out at runtime that Person "has many" Chairs and Pens, and vice versa?  I'm looking for a method that would return an array of strings (if such a method exists).  i.e. </p>
  
  <pre><code>Person.has_many_assocations 
  </code></pre>
  
  <p>would return: </p>
  
  <pre><code>["chairs", "pens"] 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Pen.belongs_to_associations
  </code></pre>
  
  <p>would return:</p>
  
  <pre><code>["person"]
  </code></pre>
  
  <p>Am I missing a method like this that exists??</p>
  
  <p>Thanks for your help. </p>