tracks/app/models/tagging.rb

18 lines
296 B
Ruby
Raw Normal View History

2008-12-22 23:26:38 +01:00
# The Tagging join model.
2008-12-22 23:26:38 +01:00
class Tagging < ActiveRecord::Base
2013-05-27 12:44:31 +02:00
2008-12-22 23:26:38 +01:00
belongs_to :tag
belongs_to :taggable, :polymorphic => true, :touch => true
2013-02-19 07:54:09 -07:00
after_destroy :delete_orphaned_tag
private
2013-02-19 07:54:09 -07:00
def delete_orphaned_tag
tag.destroy if tag and tag.taggings.count == 0
end
2008-12-22 23:26:38 +01:00
end