Sha256: 95eafc8ca4d3eff31b8d1cb568760b604cb0869675246fbf991a1c5b0a9994b0

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

=== WARNING: From version 1.2.0 and above "slug" method has been renamed to "has_slug".

---

{<img src="https://codeclimate.com/github/museways/slugs.png" />}[https://codeclimate.com/github/museways/slugs] {<img src="https://secure.travis-ci.org/museways/slugs.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/slugs] {<img src="https://gemnasium.com/museways/slugs.png" alt="Dependency Status" />}[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" }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slugs-1.2.3 README.rdoc