tracks/app/models/tagging.rb

20 lines
334 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
attr_accessible :taggable_id, :tag
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