Mongoid Smart Tags provide module that helps easily create and manage tagged documents. It's dead simple, but has some "smart" features.
Add gem to your Gemfile:
Add module to your model:
class Girl include Mongoid::Document include Mongoid::SmartTags field :name, type: String end
Suppose you have a huge tagged collection of pictures of pretty girls. You can organize and search it like this:
girl = Girl.create(name: 'Pamela Anderson', tags: 'hot wears_bikini huge_boobs blonde') # or girl = Girl.create(name: 'Pamela Anderson', tags: [ 'hot', 'wears_bikini', 'huge_boobs', 'blonde' ]) girl.tags # => [ 'hot', 'wears_bikini', 'huge_boobs', 'blonde' ] # search for girls who are hot AND are brunettes. Girl.search_by_tags('hot brunette') # now hot blonde girls who wear bikini but without huge boobies Girl.search_by_tags('hot blonde wears_bikini -huge_boobs')
Smart Tags requires Ruby 1.9.3
Mongoid Smart Tags is released under the MIT license: http://www.opensource.org/licenses/MIT