No commit activity in last 3 years
No release in over 3 years
This is plugin for easy creating unique slugs from other properties.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

About

This is plugin for easy creating unique slugs from other properties.

Initialization

You need to have DataMapper model with property slug. To set slug just use before create hook with set_slug model method. This method takes the slug as parameter. Use String#to_slug to get this parameter if you need.

class Post
  include DataMapper::Resource
  is :sluggable
  property :title, String
  property :slug,  String, :key => true
  before :create do
    set_slug(self.title.to_slug)
  end
end

So what exactly set_slug does? It look for given slug, if not found than save it, let say as “foo-bar”. If found, than increase number of iteraction and tries it again with “foo-bar-2”.