Project

slugtastic

0.0
No commit activity in last 3 years
No release in over 3 years
A simple slug string generator for ActiveRecord. Will populate a slug attribute from another attribute.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.3
~> 3.7
 Project Readme

Slugtastic

Codeship Status for danbee/slugtastic

Gem Version

Simple gem for autogenerating permalink style slugs for your ActiveRecord models.

Requirements

  • Ruby 2.2.0+
  • Rails 5 or higher.

It will probably work just find with earlier versions--down to Rails 3.1 and Ruby 1.9.3--but it's not tested.

Installation

Add this line to your application's Gemfile:

gem "slugtastic"

And then execute:

$ bundle

Or install it yourself as:

$ gem install slugtastic

Usage

Usage is very simple. Just add the following to your model:

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.

There are no extra options at present.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request