Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huacnlee/mongoid_taggable_on
Taggable on custom fields for Mongoid
https://github.com/huacnlee/mongoid_taggable_on
mongodb mongoid mongoid-plugin rails tag tagging
Last synced: about 1 month ago
JSON representation
Taggable on custom fields for Mongoid
- Host: GitHub
- URL: https://github.com/huacnlee/mongoid_taggable_on
- Owner: huacnlee
- License: mit
- Created: 2012-03-21T13:45:13.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2019-07-16T02:47:37.000Z (over 5 years ago)
- Last Synced: 2024-12-20T13:03:34.581Z (about 2 months ago)
- Topics: mongodb, mongoid, mongoid-plugin, rails, tag, tagging
- Language: Ruby
- Homepage:
- Size: 38.1 KB
- Stars: 17
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Mongoid Taggable On
Mongoid Taggable provides some helpers to create taggable documents, can use many fields.
## Status
[![CI Status](https://api.travis-ci.org/huacnlee/mongoid_taggable_on.svg)](http://travis-ci.org/huacnlee/mongoid_taggable_on) [![Gem Version](https://badge.fury.io/rb/mongoid_taggable_on.svg)](https://rubygems.org/gems/mongoid_taggable_on)
## Installation
You can simple install from rubygems:
```bash
gem install mongoid_taggable_on
```or in Gemfile:
```rb
gem "mongoid_taggable_on"
```## Usage
```ruby
class Movie
include Mongoid::Document
include Mongoid::TaggableOntaggable_on :actors, index: false
taggable_on :directors
taggable_on :countriesfield :title
field :summary
end
```Now you can use sample:
```bash
irb> movie = Movie.new
irb> movie.actor_list = "Jason Statham, Joseph Gordon-Levitt, Johnny Depp, Nicolas Cage"
irb> movie.actors
["Jason Statham", "Joseph Gordon-Levitt", "Johnny De", "Nicolas Cage"]irb> movie.country_list = "United States| China|Mexico"
irb> movie.countries
["United States", "China","Mexico"]
```find with tag:
```bash
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 [720p.so](http://720p.so), the Movie actors, directors, languages, countries, tags all base in mongoid\_taggable\_on.