tracks/app/models/tagging.rb
Jyri-Petteri Paloposki d4c9041ccd More code style fixes
2021-01-06 03:47:35 +02:00

13 lines
275 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 && tag.taggings.count == 0
end
end