mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-21 21:40:48 +02:00
13 lines
275 B
Ruby
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
|