0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Simple tagging system for Ruby on Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 4.0.0.rc1
 Project Readme

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