Created: 2012-03-21 13:45
Updated: 2017-07-18 01:45

Mongoid Taggable On

Mongoid Taggable provides some helpers to create taggable documents, can use many fields.


  • Gem Version
  • CI Status


You can simple install from rubygems:

gem install mongoid_taggable_on

or in Gemfile:

gem 'mongoid_taggable_on'



class Movie
  include Mongoid::Document
  include Mongoid::TaggableOn

  taggable_on :actors, :index => false
  taggable_on :directors
  taggable_on :countries

  field :title
  field :summary

Now you can use sample:

irb> m =
irb> m.actor_list = "Jason Statham, Joseph Gordon-Levitt, Johnny Depp, Nicolas Cage"
irb> m.actors
["Jason Statham", "Joseph Gordon-Levitt", "Johnny De", "Nicolas Cage"]
irb> m.country_list = "United States| China|Mexico"
irb> m.countries
["United States","China","Mexico"]

find with tag:

irb> Movie.tagged_with_on(:actors, "Jason Statham, Joseph Gordon-Levitt")
irb> Movie.tagged_with_on(:actors, "Jason Statham, Joseph Gordon-Levitt", :match => :any)
irb> Movie.tagged_with_on(:actors, "Nicolas Cage", :match => :not)

Allow split chars

, ,| /

Who used that?

In, the Movie actors, directors, languages, countries, tags all base in mongoid_taggable_on.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more