I have a model which fits the following pattern:
class foo < ActiveRecord::Base
has_many :bar, :dependent => :destroy
has_many :baz, :through => :bar, :uniq => true,
:after_add => :update_baz_count,
:after_remove => :update_baz_count
def update_baz_count(record)
debugger
# stuff...
end
end
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.
Thanks.