No description or website provided.
Ruby HTML JavaScript CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app/models
db/migrate
lib
spec
.gitignore
.rspec
Gemfile
Gemfile.lock
MIT-LICENSE
README.rdoc
Rakefile
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