Tagliatelle
Installation
Add this line to your application’s Gemfile:
“by gem “tagliatelle”
“
And then execute:
“ $ bundle
“
Generate model classes and migrations:
“ $ rails generate tagliatelle:install
“
Review the generated migrations then migrate:
“ $ rake db:migrate
“
Usage
Tagliatelle expects two classes to be defined:
“by class Tag < ActiveRecord::Base include Tagliatelle::Tag end
class Tagging < ActiveRecord::Base include Tagliatelle::Tagging end
“
You can add or override behavior to these classes as needed.
Then to make an object taggable:
“by class Article < ActiveRecord::Base include Tagliatelle::Taggable end
“
To tag an object:
“by article = Article.first article.tag_list = “foo, bar” article.save
“
To retrieve the tags of an object:
“by article = Article.first article.tag_list
“
To query objects based on tags:
“by Article.tagged_with([foo, bar])
“