title: Should I use the foreign_key clause both in has_many as in belongs_to?
body: <p>I have two models. <code>Office</code> and <code>Employee</code>. <code>Employee</code> has <code>office_id</code> as foreign_key. The tables was generated under a namespace. So, which is the correct?</p>
  
  <pre><code>class MyNamespace::Office &lt; ActiveRecord::Base
    has_many :employees, foreign_key: 'office_id'
  end
  
  class MyNamespace::Employee &lt; ActiveRecord::Base
    belongs_to :office, foreign_key: 'office_id'
  end
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>class MyNamespace::Office &lt; ActiveRecord::Base
    has_many :employees
  end
  
  class MyNamespace::Employee &lt; ActiveRecord::Base
    belongs_to :office, foreign_key: 'office_id'
  end
  </code></pre>
  
  <p>I think the second example is the correct, because to me, doesn't makes sense declare the foreign_key in a <code>has_many</code> relation. A coworker thinks the first example is the correct. But I haven't found too many references to this subject. So, does Anybody know which is the correct example and why? </p>