title: ruby on rails after_remove, after_add callbacks on has_many :through
body: <p>I have a model which fits the following pattern:</p>
  
  <pre><code>class foo &lt; ActiveRecord::Base
  
    has_many :bar, :dependent =&gt; :destroy
  
    has_many :baz, :through =&gt; :bar, :uniq =&gt; true,
      :after_add =&gt; :update_baz_count,
      :after_remove =&gt; :update_baz_count
  
    def update_baz_count(record)
      debugger
      # stuff...
    end
  end
  </code></pre>
  
  <p>I am try to maintain a count of unique baz's associated with foo through bar. But for some reason, the after_add and after_remove callbacks are never called when I add a bar (which has to have a baz) to foo. Any ideas why? I have used these callbacks with habtm and they work fine.</p>
  
  <p>Thanks.</p>