In my use case, I’m wanting to fire off an auditing method when a polymorphic object is added to a particular collection. When one of these objects are added to a collection stemming from a Foo object, the auditing needs to take place. But when this object is assigned/created within the scope of a Bar object, which also has_many of these objects, nothing should happen.
Granted, I could rig after_save to check to see if its parent is a Foo, and also check to see if the associated_id has changed to simulate what I’m attempting to achieve - but these collection callbacks seemed to make more sense than doing it that way.
Even the test suite seems to lend itself to only triggering on physical records:
has_many :posts_with_callbacks, :class_name => “Post”, :before_add => :log_before_adding,
:after_add => :log_after_adding,
:before_remove => :log_before_removing,
:after_remove => :log_after_removing
Logging an object that doesn’t actually exist would quickly cause issues, as it did in my use case, IMO.