norbauer / salty_slugs
salty_slugs
PublicRails abstraction of word-based slugs for URLs, w/ or w/o leading numeric IDs.
8 filesupdated Jun 18, 2026
files6Download
./libJun 16, 2026./testJun 16, 2026init.rbJun 16, 2026MIT-LICENSEJun 16, 2026RakefileJun 16, 2026README.markdownJun 18, 2026README
SaltySlugs
Abstraction of word-based slugs for URLs, w/ or w/o leading numeric IDs.
Installation
- Using Rails 2.1+
Instructions
- SaltySlugs defaults to
titleas thesource_column,slugas theslug_column, and prepends the model ID. Upon creating/updating a record, the plugin will sluggify thesource_columnwhen theslug_columnis empty, otherwise it will sluggify theslug_columnunless theslug_syncoption is set to true (defaults to false).
- You can also overwrite the defaults
- Use the
slugged_findclass method in your controllers, smart enough to modify the search conditions if prepending ID is found or not.slugged_findis capable of accepting standardActiveRecord::Base#findoptions as a second parameter. If no records are found,ActiveRecord::RecordNotFoundis raised to match behavior ofActiveRecord::Base#find.
- If the
sync_slugoption is set to true, thesource_columnwill always be sluggified upon updating the record. This means that the slug will not be able to be manually edited, but will always be synchronized to thesource_column.
TODO
- Add a word/regexp blacklist, so that they are sliced out of a string when sluggified (for example to remove .com, .net, etc)
Copyright (c) 2008 Norbauer Inc, released under the MIT license <br/>Written by Jonathan Dance and Jose Fernandez