Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Tagging plugin for Ruby on Rails apps

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 templates
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 tagger.gemspec
README.rdoc

Tagger

Installing

  1. Install it with gem install tagger

  2. Generate the migration files with rails generate tagger:install.

  3. Finally, run the migrations with rake db:migrate.

Usage

Add the method call taggable to your model.

class Link < ActiveRecord::Base
  taggable :scope => :category
  belongs_to :category
end

class Category < ActiveRecord::Base
  has_many :links
end

@post = Post.first
@category = Category.first

# set tags using the chosen tag separator
@post.tagged_with = "rails, activerecord, models"

# get tags joined with the chosen tag separator
@post.tagged_with

# get all tags as objects
@post.tags

# check if an user tagged this object
@post.tag_owner?(current_user)

# generate a tag cloud
@tags = Tag.cloud(:link, :limit => 100, :scope => @category)

# at the view, call the helper tag_cloud
tag_cloud @tags do |tag_name, css|
  <%= link_to tag_name, tag_path(tag_name), :class => css
end

Copyright © 2008 Nando Vieira, released under the MIT license

Something went wrong with that request. Please try again.