Perhaps you can create your own models to support this (and all you want) ...
I think you can achieve this 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 use any behavior and data for your tags.
Hope this helps you!
Rudy seidinger
source share