Sha256: b105b9648307c5538f580c0e70bf96b740f3e4db47fdf6d3dc24a24b21496d35

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

=== NOTE: From version 1.0.5 and above a index it appended if a new slug it's equal to a old one

---

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_slugs-1.0.10 README.rdoc
rails_slugs-1.0.9 README.rdoc
rails_slugs-1.0.8 README.rdoc
rails_slugs-1.0.7 README.rdoc