=== WARNING: From version 1.2.0 and above "slug" method has been renamed to "has_slug".
---
{}[https://codeclimate.com/github/museways/slugs] {}[https://travis-ci.org/museways/slugs] {}[https://gemnasium.com/museways/slugs]
= Slugs
Inspired in friendly_id but more minimalistic.
= Install
Put this line in your Gemfile:
gem 'slugs'
Then bundle:
$ bundle
= Usage
Add the column in your migration:
t.string :slug
(If you are using translatable_records 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 has_slug method in your model:
If you want to use the value of one field:
has_slug :prop
To concatenate the value of multiple fields:
has_slug :prop1, :prop2, :prop3
Or if you need a very custom slug you can use a lambda, proc or block:
has_slug proc { |record| "#{record.prop}-custom" }