title: DRYing up my Rails belongs_to and has_many assosiations
body: <p>I'm working on an app that works out debts and who owes what to whom etc..</p>
  
  <p>Currently it works like this:</p>
  
  <pre><code>create_table "debts", :force =&gt; true do |t|
    t.string   "amount"
    t.integer  "payer_id"
    t.integer  "payee_id"
    t.datetime "created_at", :null =&gt; false
    t.datetime "updated_at", :null =&gt; false
  end
  
  create_table "people", :force =&gt; true do |t|
    t.string   "name"
    t.integer  "bank"
    t.datetime "created_at", :null =&gt; false
    t.datetime "updated_at", :null =&gt; false
  end
  
  class Debt &lt; ActiveRecord::Base
      attr_accessible :amount, :payee_id, :payer_id
  
      belongs_to :payee, :class_name =&gt; 'Person'
      belongs_to :payer, :class_name =&gt; 'Person'
   end
  
  class Person &lt; ActiveRecord::Base
      attr_accessible :amount, :payee_id, :payer_id
  
      has_many :debts_owed, :class_name =&gt; Debt, :foreign_key =&gt; "payee_id"
      has_many :debts_to_pay, :class_name =&gt; Debt, :foreign_key =&gt; "payer_id"
  end
  </code></pre>
  
  <p>It's working but I know there must be a simpler way of representing multiple associations to the same model? I've been reading up on has_and_belongs_to_many which looks like the right thing but I'm lost to be honest.</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>Thanks</p>