tracks/app/models/tagging.rb
Jyri-Petteri Paloposki d8acf60049 Code style fixes
2020-10-10 05:14:24 +03:00

13 lines
276 B
Ruby

# The Tagging join model.
class Tagging < ApplicationRecord
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