1
0
mirror of https://github.com/danbee/danbarber.me synced 2025-03-04 08:59:10 +00:00
danbarber.me/_posts/2012-08-21-slugtastic-v1.0.0.markdown
2015-02-08 17:09:34 +00:00

18 lines
722 B
Markdown

---
layout: post
title: "Slugtastic v1.0.0"
date: 2012-08-21 10:09
comments: true
categories: rubygems gem rails coding
published: true
---
I've just released my first proper Ruby gem. It's a simple permalink style slug generator for ActiveModel. Check it out at [Github](https://github.com/danbee/slugtastic) and use it in your Rails project by adding `gem "slugtastic"` to your Gemfile.
Usage is very simple. Just add the following to your model:
``` ruby
has_slug :slug, :from => :title
```
This will generate a slug string from the title attribute and store it in the slug attribute unless the slug already contains a string. The slug is generated pre-validation so you can still use `validates_presence_of :slug`.