删除关系未被审核 gem

Removing relations is not being audited by audited gem

我正在使用 Associated Audits on a has_many through relation with Collective Idea's audited gem。我看到正在添加 through 模型的 create 审计,但是删除该关系后我没有看到任何审计。

这是我的 3 个模型。一个Post可以在多个Categories.

app/models/post.rb

class Post < ActiveRecord::Base
  audited
  has_associated_audits

  has_many :categorizations, dependent: :destroy
  has_many :categories, through: :categorizations
end

app/models/category.rb

class Category < ActiveRecord::Base
  audited
  has_associated_audits

  has_many :categorizations, dependent: :destroy
  has_many :posts, through: :categorizations
end

app/models/categorization.rb

class Categorization < ActiveRecord::Base
  audited
  audited associated_with: :post
  audited associated_with: :category

  belongs_to :category
  belongs_to :post
end

我的 Post 表单有一堆用于分类的复选框:

<%= f.association :categories, as: :check_boxes, collection: Category.order(:name), label_method: :name, value_method: :id, label: false %>

可能与 this Rails issue 有关,我不得不换掉我的 dependent: :destroy 行:

app/models/post.rb

class Post < ActiveRecord::Base
  audited
  has_associated_audits

  has_many :categorizations
  has_many :categories, through: :categorizations, dependent: :destroy
end

app/models/category.rb

class Category < ActiveRecord::Base
  audited
  has_associated_audits

  has_many :categorizations
  has_many :posts, through: :categorizations, dependent: :destroy
end

有了这个设置,我看到了添加和删除关系的审核。