Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 db
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
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 simple_tags.gemspec
README.rdoc

SimpleTags

Simple tagging system for ruby on rails.

Instalation

# Gemfile
gem 'simple_tags'

rails g simple_tags:migrations
rake db:migrate

Configuration

You should add the Taggings module to the models you want to tag:

class SomeTaggableModel < ActiveRecord::Base
  include SimpleTags::Taggable
end

That's it, no configuration needed. Include `SimpleTags::Taggable` to every model you want to tag.

Use

Adding tags

model = SomeTaggableModel.first
model.tags << [SimpleTags::Tag.create(name: 'cool'), SimpleTags::Tag.create(name: 'nice')

model = SomeTaggableModel.first
model.tag_list = "cool, nice"

Listing Tags

model = SomeTaggableModel.first
model.tags
# Active relation tag list

model = SomeTaggableModel.first
model.tag_list
# String with tag names separated by commas

Taggable listings

Dynamic associations are created everytime you include `SimpleTags::Taggable` to a model. For example:

class Article < ActiveRecord::Base
  include SimpleTags::Taggable
end

# after that, the Tag models will have an `articles` relation

tag = SimpleTags::Tag.first
tag.articles

You can list all taggings of a tag using the `taggings` relation:

tag.taggings

License

MIT License. Copyright 2012 Tiago Scolari

Something went wrong with that request. Please try again.