title: Eager Loading in a Rails 3 app
body: <p>I am trying to reduce the number of database queries in my Rails 3 app.</p>
  
  <p>User model:</p>
  
  <pre><code>has_many :agreements
  </code></pre>
  
  <p>Agreement model:</p>
  
  <pre><code>belongs_to :user
  </code></pre>
  
  <p>The agreements table has two user id fields... payer_id and payee_id. Is it possible to make something like the following work:</p>
  
  <pre><code>user_payer_agreements = current_user.agreements
  user_payee_agreements = current_user.agreements
  </code></pre>
  
  <p>I could use user_id for one side of the transaction but I need to get both sides. Is it possible to specify payer_id or payee_id instead of user_id in the process of creating an association? If not, do i need use a join or a sql statement. Any help is appreciated.</p>