https://github.com/tomasc/mongoid_permalink_extension
Custom field type for Mongoid that automatically converts strings to URL slugs.
https://github.com/tomasc/mongoid_permalink_extension
Last synced: 8 months ago
JSON representation
Custom field type for Mongoid that automatically converts strings to URL slugs.
- Host: GitHub
- URL: https://github.com/tomasc/mongoid_permalink_extension
- Owner: tomasc
- License: mit
- Created: 2014-07-08T07:58:22.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T12:08:00.000Z (about 8 years ago)
- Last Synced: 2025-10-07T23:42:14.278Z (9 months ago)
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mongoid Permalink Extension
[](https://travis-ci.org/tomasc/mongoid_permalink_extension) [](http://badge.fury.io/rb/mongoid_permalink_extension) [](https://coveralls.io/r/tomasc/mongoid_permalink_extension)
A [Mongoid](https://github.com/mongoid/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:
```ruby
field :permalink, type: MongoidPermalinkExtension::Permalink
```
Produces slugs in the form of:
A-Hard-Days-Night
See tests for more examples.
## 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