Acts As Taggable On Steroids is based on acts_as_taggable by DHH but includes extras such as
tests, smarter tag assignment, and tag cloud calculations.
For a number of applications, especially our Tutor Social Platform - Tutor Metro, We’ve found a need for advanced tagging functionality not offered by the acts_as_taggable_on_steroids plugin.
for instance, we will wished a model could have multiple “sets” of tags that would function both independently and together and named scope support
That’s where acts_as_taggable_on comes in.
From mbleigh :
For instance, in a social network, a user might have tags that are called skills, interests, sports, and more. There is no real way to differentiate between tags and so an implementation of this type is not possible with acts as taggable on steroids. Enter Acts as Taggable On. Rather than tying functionality to a specific keyword (namely “tags”), acts as taggable on allows you to specify an arbitrary number of tag “contexts” that can be used locally or in combination in the same way steroids was used.
To install, that is very simple from the project site, however, if we want to migrate from taggable on steroids in previous project, we have to do some more tweaking :
1. install gems or plugin as normal
2. generate the migration as usual
script/generate acts_as_taggable_on_migration
3. suppose you have an acts_as_taggable migration before, we have to do less in this migration . modify the migration as following
class ActsAsTaggableOnMigration < ActiveRecord::Migration
def self.up
remove_index :taggings, [:taggable_id,:taggable_type]
add_column :taggings, :tagger_id, :integer
add_column :taggings, :tagger_type, :string
add_column :taggings, :context, :string
t.column :tagger_id, :integer
t.column :tagger_type, :string
t.column :context, :string
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
t.column :taggable_id, :integer
t.column :tagger_id, :integer
t.column :tagger_type, :string
# You should make sure that the column created is
# long enough to store the required class names.
t.column :taggable_type, :string
t.column :context, :string
t.column :created_at, :datetime
end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context] , :name => ‘index_taggings’
end
def self.down
remove_index :taggings, :name => 'index_taggings'
add_index :taggings, [:taggable_id, :taggable_type]
remove_column :taggings, :tagger_id
remove_column :taggings, :tagger_type
remove_column :taggings, :context
drop_table :taggings
drop_table :tags
end
end
4. rake db:migrate
5. add parameters to the acts_as_taggable_on
class Photo < ActiveRecord::Base acts_as_taggable_on :tagsend
6. fix your code on getting the tag list
7. do your testing, and you may have it done, cheer !
Leave a reply