mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-23 18:50:12 +01:00
19 lines
334 B
Ruby
19 lines
334 B
Ruby
|
|
# The Tagging join model.
|
|
|
|
class Tagging < ActiveRecord::Base
|
|
|
|
attr_accessible :taggable_id, :tag
|
|
|
|
belongs_to :tag
|
|
belongs_to :taggable, :polymorphic => true, :touch => true
|
|
|
|
after_destroy :delete_orphaned_tag
|
|
|
|
private
|
|
|
|
def delete_orphaned_tag
|
|
tag.destroy if tag and tag.taggings.count == 0
|
|
end
|
|
|
|
end
|