SimpleSlug
Simple friendly url generator for ActiveRecord models with history.
Installation
Add this line to your application's Gemfile:
gem 'simple_slug'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_slug
Usage
Add basic slugs to your model:
class User < ActiveRecord::Base
simple_slug :full_name
endOr with custom slug column and history:
class User < ActiveRecord::Base
simple_slug :full_name, slug_column: 'my_slug_column', history: true
endAdd localization with slug_YOUR_LOCALE like columns:
class User < ActiveRecord::Base
simple_slug :full_name, locales: [nil, :it]
endIf you want to control when slug is generated, define should_generate_new_slug? method:
class User < ActiveRecord::Base
simple_slug :full_name
def should_generate_new_slug?
true
end
endContributing
- Fork it ( http://github.com/leschenko/simple_slug/fork )
- 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