tracks/app/models/tagging.rb

14 lines
335 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
2008-12-22 23:26:38 +01:00
belongs_to :tag
belongs_to :taggable, :polymorphic => true
2008-12-22 23:26:38 +01:00
# This callback makes sure that an orphaned <tt>Tag</tt> is deleted if it no longer tags anything.
def after_destroy
tag.destroy_without_callbacks if tag and tag.taggings.count == 0
end
2008-12-22 23:26:38 +01:00
end