Awesome
mongoid-tags
Mongoid::Tags adds a simple tagging system to your Mongoid documents, and allows you to query them using a boolean search syntax.
Installation
In your Gemfile:
gem 'mongoid-tags'
Usage
class Document
include Mongoid::Document
include Mongoid::Tags
end
# Documents tagged foo || bar
Document.tagged('foo bar')
# Documents tagged foo && bar
Document.tagged('+foo bar')
# Documents tagged foo, but !bar
Document.tagged('foo -bar')
# Documents tagged foo and bar or baz
Document.tagged('(+foo +bar) baz')
# Documents tagged foo and bar, or foo and baz
Document.tagged('(+foo +bar)(+foo +baz)')
# Chaining calls
Document.where(published: true).tagged('foo').desc(:created_at)
Be sure to checkout test/integration_test.rb for more examples.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright
(The MIT license)
Copyright (c) 2012-2016 Mario Uher
See LICENSE.md.