Tag: 被审计的行为

在HABTM关系中的连接表中是否调用了ActiveRecord回调?

在测试acts_as_audited时 ,我发现(如此处所述):with_associations标志不会为HABTM关系生成审计表条目。 例如: 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 (和测试的变化,即有/无with_associations) 在源代码中,可以看到所有acts_as_audited都会在审计表中添加像before_update和after_create这样的回调。 显然这些不会添加到连接表中。 我尝试制作如下模型: GroupsUsers < ActiveRecord::Base acts_as_audited after_save: :test def test logger.debug "test" end 但没有看到对用户或组的CRUD操作的审计表的任何添加。 我可以在日志中看到作用于连接表的SQL语句,因此这表明连接表在内部被更改,以便绕过正常的回调。 这是真的? 获取acts_as_audited以通知连接表或记录HABTM关联的任何建议?