Plugins - ActsAsTaggableOn
Add to favoritesActsAsTaggableOn provides an 'acts' framework upon which a single model can have multiple static or dynamic tag contexts.
Installation
To install the plugin, simply get it straight from our public SVN repository:
script/plugin install http://svn.intridea.com/svn/public/acts_as_taggable_on/
Then you will need to generate the migration for tags and taggings. This should do the trick:
script/generate acts_as_taggable_on_migration
Usage
Acts As Taggable On provides the same functionality of actsas_taggableon_steroids with the addition of the notion of "contexts," or scoped areas in which taggings can live. For the user example listed above, I can now simply make a call like so:
class User < ActiveRecord::Base
acts_as_taggable_on :tags, :skills, :interests, :sports
end
By taking the same one-liner tack as previous implementations, we are now able to set, find, retrieve, and calculate information based on tags within a context as well as as a whole. With the user model we just created:
@user = User.new(:name => "Bobby")
@user.tag_list = "awesome, slick, hefty" # this should be familiar
@user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
@user.skill_list # => ["joking","clowning","boxing"] as TagList
@user.save
@user.tags # => [{Tag name:"awesome"},{Tag name:"slick"},{Tag name:"hefty"}]
@user.skills # => [{Tag name:"joking"},{Tag name:"clowning"},{Tag name:"boxing"}]
User.find_tagged_with("awesome", :on =} :tags) # =} [@user]
User.find_tagged_with("awesome", :on =} :skills) # =} []
@frankie = User.create(:name =} "Frankie", :skill_list =} "joking, flying, eating")
User.skill_counts # => [{Tag name="joking" count=2},{Tag name="clowning" count=1}...]
@frankie.skill_counts
Dynamic Contexts
In addition to the generated tag contexts in the definition, it is also possible to allow for dynamic tag contexts (this can be user-generated tag contexts!)
@user = User.new(:name => "Bobby")
@user.set_tag_list_on(:customs, "same, as, tag, list")
@user.tag_list_on(:customs) # => ["same","as","tag","list"]
@user.save
@user.tags_on(:customs) # => [,...]
@user.tag_counts_on(:customs)
User.find_tagged_with("same", :on => :customs) # => [@user]
And that's all there is to it! Now you can scope your tags to whatever arbitrary name you would like. The inflector is used to create the singular/plural methods, so be careful about making sure that your nomenclature uses plurals in the actsas_taggableon call.
As a side note, this is meant to be used in place of actsas_taggableonsteroids, and the actsastaggable method works in actsastaggableon simply by calling actsas_taggableon :tags. Caching has been written into the implementation but is not yet tested or verified to be working. Stay tuned for additional improvements to this plugin, and feel free to submit any bugs or patches to the Intridea Open Source Trac
http://www.intridea.com/2007/12/4/announcing-acts_as_taggable_on
http://github.com/mbleigh/acts-as-taggable-on/tree/master
Rails' (MIT)
Model

Is it possible to calculate the tag counts for the ALL taggable_types ?