SimpleSlug

Build Status

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
end

Or with custom slug column and history:

class User < ActiveRecord::Base
  simple_slug :full_name, slug_column: 'my_slug_column', history: true
end

Add localization with slug_YOUR_LOCALE like columns:

class User < ActiveRecord::Base
  simple_slug :full_name, locales: [nil, :it]
end

If 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
end

Contributing

  1. Fork it ( http://github.com/leschenko/simple_slug/fork )
  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