tracks/app/models/tagging.rb

14 lines
275 B
Ruby
Raw Normal View History

# The Tagging join model.
class Tagging < ApplicationRecord
2008-12-22 23:26:38 +01:00
belongs_to :tag
belongs_to :taggable, :polymorphic => true, :touch => true
2014-08-14 21:05:05 -05:00
2013-02-19 07:54:09 -07:00
after_destroy :delete_orphaned_tag
2014-08-14 21:05:05 -05:00
private
2014-08-14 21:05:05 -05:00
2013-02-19 07:54:09 -07:00
def delete_orphaned_tag
2020-10-27 21:39:19 +02:00
tag.destroy if tag && tag.taggings.count == 0
end
2008-12-22 23:26:38 +01:00
end