0.0
Low commit activity in last 3 years
A Rails plugin to generate configurable slugs for models, replacing ID-based URLs with user-friendly identifiers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 6.0.0
 Project Readme

RailsSluggable

A Rails plugin for generating configurable model slugs.

Usage

# generate slug for `Posts`
rails generate migration AddSlugToPosts slug:string:uniq

class Post < ApplicationRecord
  sluggable length: 12
end

class Article < ApplicationRecord
  sluggable length: 8, separator: '-'
end

Example

Use slug for post model.

{
  "id": 1,
  "content": "Ruby on Rails 是一个强大的 Web 开发框架...",
  "created_at": "2025-11-07T06:48:29.259Z",
  "slug": "077f802de102",
  "title": "Rails 入门指南",
  "updated_at": "2025-11-07T06:48:29.259Z"
}

Installation

Add this line to your application's Gemfile:

gem "rails_sluggable"

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_sluggable

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.