=== NOTE: From version 1.0.5 and above a index it appended if a new slug it's equal to a old one
---
{
}[https://codeclimate.com/github/mattways/rails_slugs] {
}[https://travis-ci.org/mattways/rails_slugs] {
}[https://gemnasium.com/mattways/rails_slugs]
= Rails Slugs
Inspired in friendly_id but more minimalistic.
= Install
Put this line in your Gemfile:
gem 'rails_slugs'
Then bundle:
$ bundle
= Usage
Add the column in your migration:
t.string :slug
(If you are using rails-i18n-record you need to place the column in the translation table, this has been done this way because it's easier to maintain and your queries will be faster avoiding extra joins)
Update your db:
rake db:migrate
Call the slug method in your model:
If you want to use the value of one field:
slug :prop
To concatenate the value of multiple fields:
slug :prop1, :prop2, :prop3
Or if you need a very custom slug:
slug proc { |record| "#{record.prop}-custom" }