tracks/app/models/tagging.rb
Matt Rogers 0e21d64890
Convert to ApplicationRecord
Rails 5 requires the use of this superclass for all database backed
model objects now.
2018-11-03 15:57:14 -05:00

17 lines
280 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