Rails gem for automatically creating slug column for your model
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gemtest
.gitignore
Gemfile
LICENSE
README.md
Rakefile
sluggerize.gemspec

README.md

Sluggerize

A simple plugin that automatically generates a url friendly version of a column (a slug) for a model on create.

Usage

sluggerize :source_column, [options]

Source Column

If you don't provide a source column, it will default to looking for a "title" column.

Options

  • as_params [False] If true, this will be used as the id of the object when creating URLs and you will be able to Object.find(slug)
  • substitution_char - [-] The character to use when replacing spaces and other unsupported characters

Example

create_table "projects" do |t|
  t.string   "title"
  t.string   "slug"
end

class Project < ActiveRecord::Base
  sluggerize
end

Project.create(:title => 'A Very Happy Project')
Project.first.slug
=> 'a-very-happy-project'

Copyright (c) 2011 Jeremy Hubert, released under the MIT license