title: Soft-delete on has_many through association
body: <p>What is the easiest way to implement <strong>soft-deletes on has_many through</strong> association?</p>
  
  <p>What I want is something like this:</p>
  
  <pre><code>class Company &gt; ActiveRecord::Base
    has_many :staffings
    has_many :users, through: :staffings, conditions: {staffings: {active: true}}
  end
  </code></pre>
  
  <p>I want to use <code>Company#users</code> the following way:</p>
  
  <ul>
  <li>the <code>Company#users</code> should be a normal association so that it <strong>works with forms</strong> and doesn't break existing contract.</li>
  <li>when adding a <strong>user</strong> to the company, a new <code>Staffing</code> with <code>active: true</code> is <strong>created</strong>.</li>
  <li>when <strong>removing</strong> a user from a company, the existing <code>Staffing</code> is updated <code>active: false</code> (currently it <strong>just gets deleted</strong>).</li>
  <li>when adding a <strong>previously removed user</strong> to the company (so that <code>Staffing#active == false</code>) the <code>Staffing</code> is updated to <code>active: true</code>.</li>
  </ul>
  
  <p>I thought about overriding the <code>Company#users=</code> method, but it really isn't good enough since there are other ways of updating the associations.</p>
  
  <p>So the question is: <strong>how to achieve the explained behaviour on the <code>Company#users</code> association?</strong></p>
  
  <p>Thanks.</p>