Maybe you can create your own models to support this (and anything else you want)...
I think you can achieve that by doing something like:
class Tag < ActiveRecord::Base
end
class Tagging < ActiveRecord::Base
validates_presence_of :tag_id
belongs_to :tag
belongs_to :taggable, :polymorphic => true
end
class ModelIWantToBeTagged < ActiveRecord::Base
include ModelTagging
has_many :taggings, :as => :taggable
end
module ModelTagging
def add_tag(tag_name)
tag = Tag.find_or_create_by_tag(tag_name)
tagging = Tagging.new
tagging.taggable_id = self.id
tagging.taggable_type = get_class_name
tagging.tag_id = tag.id
tagging.save!
end
def remove_tag(tag_name)
tag = Tag.find_by_tag(tag_name)
Tagging.where(:tag_id => tag).delete_all
end
private
def get_class_name
self.class.name
end
end
This way you can any behavior and data to your tags.
Hope it helps you!
_with_aliases
did it? – Faruq