While testing acts_as_audited, I discovered (as also described here) that the :with_associations flag does not produce audit table entries for HABTM relationships.
For example:
User < ActiveRecord::Base
has_and_belongs_to_many: :groups
acts_as_audited, with_associations: groups
Group < ActiveRecord::Base
has_and_belongs_to_many: :users
acts_as_audited, with_associations: users
(and tested variations, ie. with/without with_associations)
In the source, one can see that all acts_as_audited does is adds callbacks like before_update and after_create to the audited tables. Apparently these are not added to the join tables.
I tried making a model like:
GroupsUsers < ActiveRecord::Base
acts_as_audited
after_save: :test
def test
logger.debug "test"
end
but did not see any additions to the audit table for CRUD operations on Users or Groups. I can see the SQL statement acting on the join table in the logs so this suggests that the join table is altered internally in such a way that the normal callbacks are bypassed.
Is this true? Any suggestions for getting acts_as_audited to notice the join table or to log HABTM associations?