0.0
No commit activity in last 3 years
No release in over 3 years
Mongoid Urls creates unique sanitized URLs for Mongoid documents. Simple and great for making URLs look good.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

> 4.0.0
 Project Readme

Mongoid::Urls

Gem Version Dependency Status Build Status Code Climate Coverage Status

Mongoid::Urls

Simple slugs for mongoid models! Set the fields you want to try to make an URL out of, when impossible, use your logic or set the url directly.

Nice URLs for Mongoid Documents

This library is a quick and simple way to generate URLs (slugs) for your Mongoid documents.

Mongoid::Urls can help turn this:

http://bestappever.com/video/4dcfbb3c6a4f1d4c4a000012

Into something like this:

http://bestappever.com/video/kittens-playing-with-puppies

Getting started

In your gemfile, add:

gem 'mongoid-urls'

In your Mongoid documents, just add include Mongoid::Urls and use the url method to setup, like so:

class Company
  include Mongoid::Document
  include Mongoid::Urls

  field :nickname
  field :fullname
  ...

  url :nickname, :fullname, ...
end

And that's it! There's some configuration options too - which are all listed below.

Finders

Mongoid::Urls will never override find!

Video.find_by_url("the-nice-url")

Or just:

Account.find_url("acc-123456")

Configuration

You may choose between two different systems for how your urls are stored:

Simple: #url String only.

Default to simple + #urls Array for history (find when page moved).

Reserved

Defaults to %w(new edit). Have in mind: It's an overwrite, not a merge.

Notes

If you're looking for conflict resolution, check out mongoid-slugs. This gem intended to be used for manual conflict resolution (duplicates): Use your own logic and/or return conflict error to the user.