title: Custom Association in rails
body: <p>I am finding it hard to understand some of the association defined in the code base.</p>
  <pre><code>class Patient &lt; ApplicationRecord   
      belongs_to :g_district, class_name: &quot;District&quot;, primary_key: &quot;id&quot;, foreign_key: 'district_id', optional: true
      belongs_to :g_perm_district, class_name: &quot;District&quot;, primary_key: &quot;id&quot;, foreign_key: 'permanent_district_id', optional: true
      belongs_to :g_workplc_district, class_name: &quot;District&quot;, primary_key: &quot;id&quot;, foreign_key: 'workplace_district_id', optional: true    
  end
  class District
      belongs_to :province #, optional: true
      belongs_to :division, optional: true
      has_many :hospitals
      has_many :tehsils
      has_many :ucs
      has_many :mobile_users
      has_many :labs
      has_many :insecticides
  end
  </code></pre>
  <p>I am not clearly getting these kind of associations defined her.(belongs_to :g_district, class_name: &quot;District&quot;, primary_key: &quot;id&quot;, foreign_key: 'district_id', optional: true).</p>
  <p>In my code, there are no models like g_district, g_perm_district, g_workplc_district.</p>