No commit activity in last 3 years
No release in over 3 years
Manages your slug so you don't have to.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

= 0.9.8
= 0.9.8
 Project Readme

dm-slug

Manages your permalinks so you don't have to.

Internally, makes use of DataMapper::Types::Slug, although I'm not terribly excited about its implementation at the moment. (After you save a model, you have to reload it to be able to see a proper value for the slug field.)

To use, add the following to your model:

has_slug # uses defaults of :on => name, :called => :slug

or

has_slug :on => title, :called => permalink

You can add a :length option as well, though if you place your has_slug anywhere below the property given in :on, it will pick up the length of that field and use that instead. It will also add a unique_index option if the original field has unique_index set to true, or if it's a key.

As shown above, if your field to create a slug on is called :name or if you don't mind your slug field being called slug, then you can leave that corresponding option out, as those are the defaults. If you'd like something different, as in the second example, you can specify them and they'll get used instead of the defaults.

Let me know if there's anything additional you'd like to see here.