0.0
No commit activity in last 3 years
No release in over 3 years
Simple slugging for Mongoid models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.0.1
>= 0
>= 2.9
 Project Readme

Mongoid::Slugs

Simple slugging for Mongoid models

Installation

Add this line to your application's Gemfile:

gem 'mongoid-slugs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongoid-slugs

Example Usage

class Article
  include Mongoid::Document
  include Mongoid::Slugs

  field :title
  field :content

  slug_on :title
end
article1 = Article.create(title: "This is a Test Article", content: "...")
article1.slug       #=> "this-is-a-test-article"
article1.to_param   #=> "this-is-a-test-article" 

article2 = Article.create(title: "This is a test article", content: "Another article")
article2.slug       #=> "this-is-a-test-article-1"

Article.find_by_slug("this-is-a-test-article")    #=> article1

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request