tracks/app/models/tagging.rb
2014-08-14 21:05:05 -05:00

17 lines
281 B
Ruby

# The Tagging join model.
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :taggable, :polymorphic => true, :touch => true
after_destroy :delete_orphaned_tag
private
def delete_orphaned_tag
tag.destroy if tag and tag.taggings.count == 0
end
end