Mongoid Permalink Extension
A Mongoid field extension that stores any String as a permalink slug.
- converts spaces to hyphens
- converts to camel case
- converts all dashes to hyphens
- remove non-alphanumeric characters
- removes accents
Installation
Add this line to your application's Gemfile:
gem 'mongoid_permalink_extension'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid_permalink_extension
Usage
Add to Mongoid models as:
field :permalink, type: MongoidPermalinkExtension::Permalink
Produces slugs in the form of:
A-Hard-Days-Night
See tests for more examples.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request