Skip to content

Instantly share code, notes, and snippets.

@chebyte
Created June 13, 2011 00:55
Show Gist options
  • Save chebyte/1022179 to your computer and use it in GitHub Desktop.
Save chebyte/1022179 to your computer and use it in GitHub Desktop.
mongoid tag system
= mongoid-simple-tags
mongoid-simple-tags is a basic and simple tagging system for mongoid using map-reduce function
== Install
Add the following to Gemfile:
gem "mongoid-simple-tags"
== Usage
=== Model
class User
include Mongoid::Document
include Mongoid::Document::Taggable
end
=== Console
u = User.new(:name => "Tuquito")
u.tag_list = "linux, tucuman, free software"
u.tags # => ["linux","tucuman","free software"]
u.save
User.tagged_with("linux") # => u
User.tagged_with(["tucuman", "free software"]) # => u
u2 = User.new(:name => "ubuntu")
u2.tag_list = "linux"
u2.save
User.tagged_with("linux") # => [u, u2]
== Copyright
Copyright (c) 2011 chebyte(mauro torres). See LICENSE.txt for
further details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment