Cloud Computing: The Digital Shift 2.0 – Understanding the Current Market Trends

using rails acts as taggable on plugin

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.

Plugin Installation

script/plugin install git://

Gem Installation

gem install mbleigh-acts-as-taggable-on --source

Auto Install
include following line in environment.rb

config.gem "mbleigh-acts-as-taggable-on", :source => "", :lib => "acts-as-taggable-on"

Post Installation (Rails)

1. script/generate acts_as_taggable_on_migration
2. rake db:migrate

Add following line in your model for which you wanted to be tagged.

acts_as_taggable_on :tags


class Post < ActiveRecord::Base
acts_as_taggable_on :tags

In your View for Post

In your controller create action

@post = (params[:post])
# Or just hardcode to test
@post.tag_list ="awesome, slick, hefty"

What are the methods provided ??

@post.tag_list = "awesome, slick, hefty"

Post.tagged_with("awesome", :on => :tags) # => [@post1, @post2]

Post.tag_counts # => [,...]

Named Scope

class Post "created_at DESC"


Pagination can be added on list of tags using will_paginate plugin

List Of Tags .paginate(:page => params[:page], :per_page => 20)

@post.find_related_tags # => will give related posts having related tags. [ @post1, @post2, ...]

Tag Owners

class User < ActiveRecord::Base

class Post < ActiveRecord::Base
acts_as_taggable_on :tags

@some_user.tag(@some_post, :with => "paris, normandy", :on => :tags)

Cheers !

0 thoughts on “using rails acts as taggable on plugin”

Leave a Comment

Your email address will not be published.