title: Rails: Non id foreign key lookup ActiveRecord
body: <p>I want <code>ActiveRecord</code> to lookup by a non-id column from a table.
  Hope this is clear when I give you my code sample.</p>
  
  <pre><code>class CoachClass &lt; ActiveRecord::Base
    belongs_to :coach
  end
  
  class Coach &lt; ActiveRecord::Base
      has_many :coach_classes, :foreign_key =&gt; 'user_name'
  end
  </code></pre>
  
  <p>When I do a 
  <code>coach_obj.coach_classes</code>, this rightly triggers</p>
  
  <pre><code>SELECT * FROM `coach_classes` WHERE (`coach_classes`.user_name = 2)
  </code></pre>
  
  <p>(2 being the that coach's <code>id</code> here which is my problem.)</p>
  
  <p>I want it to trigger </p>
  
  <pre><code>SELECT * FROM `coach_classes` WHERE (`coach_classes`.user_name = 'David')
  </code></pre>
  
  <p>('David' being the that coach's <code>user_name</code>)</p>
  
  <p><code>user_name</code> is unique and present in both tables.</p>
  
  <p>I do not want to have a <code>coach_id</code> in my <code>coach_classes</code> table for some reason.</p>