diff --git a/app/models/tagging.rb b/app/models/tagging.rb index 7cc321a0..c067b31e 100644 --- a/app/models/tagging.rb +++ b/app/models/tagging.rb @@ -8,12 +8,11 @@ class Tagging < ActiveRecord::Base belongs_to :tag belongs_to :taggable, :polymorphic => true, :touch => true - after_destroy :after_destroy + after_destroy :delete_orphaned_tag private - # This callback makes sure that an orphaned Tag is deleted if it no longer tags anything. - def after_destroy + def delete_orphaned_tag tag.destroy if tag and tag.taggings.count == 0 end