title: What is the class of an association based on the foreign key attribute only?
body: <p>Short: I have an foreign key attribute and want to know what is the class (or reference table) of that foreign key field.</p>
  
  <p>Context:</p>
  
  <p>given 2 tables: <code>users(id, [other fields])</code> and <code>issues(id, user_id, assigned_to, [other fields])</code></p>
  
  <p>Here is my active record of Issue (irrelevant parts are extracted)</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    ...
  end
  class Issue &lt; ActiveRecord::Base
    belongs_to :user
    belongs_to :assigned_user, :foreign_key =&gt; 'assigned_to', :class_name =&gt; 'User'
    ...
  end
  </code></pre>
  
  <p>I want to make a user readable change logging. e.g. when changing assigned user I want to get a message like this: <code>Assigned to is changed from Otto to Zoltan</code>.  ActiveRecord has the function <code>changes</code> which is a good starting point but it give me only reference ID-s. To translate into names I need to read user by id. </p>
  
  <p>For association <code>:user</code> it is quite easy because I have to follow conventions only. But how to fetch the same info for <code>assigned_to</code> attribute (I want to make a general solution)? Is it possible to figure out whether we have association for the given attribute? Can we extract the class of that association?</p>