title: Rails: Virtual Association?
body: <p>I have an Invoice model that has an status_id attribute, this model belongs to Status models.</p>
  
  <p>The Invoice.status_id can be "0 => active" or "2 => closed" in the DB.</p>
  
  <p>The thing is in my Status model i also have ":id => 1, :name => due", but this is only when the Invoice.payment_date is less than today.</p>
  
  <p>So my question is how can i something like</p>
  
  <pre><code>i = Invoice.find(:first)
  i.status.name # i need this to return due if the Invoice.status_id == 0 and
                # Invoice.payment_date &lt; Date.today
  </code></pre>
  
  <p>Obviously the above code is always returning the name based on the value Invoice.status_id, because the association is correct.</p>
  
  <p>I hope it make sense and somebody can help me.</p>
  
  <p>Thanks.</p>