tracks/app/models/tagging.rb

18 lines
281 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
2014-08-14 21:05:05 -05:00
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
tag.destroy if tag and tag.taggings.count == 0
end
2014-08-14 21:05:05 -05:00
2008-12-22 23:26:38 +01:00
end