All Projects → norman → Friendly_id

norman / Friendly_id

Licence: mit
FriendlyId is the “Swiss Army bulldozer” of slugging and permalink plugins for ActiveRecord. It allows you to create pretty URL’s and work with human-friendly strings as if they were numeric ids for ActiveRecord models.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Friendly id

Slugifier
Just a simple, clean and pure functional implementation for creating slugs
Stars: ✭ 69 (-98.8%)
Mutual labels:  slug
Slugify
Slugify a string
Stars: ✭ 2,110 (-63.41%)
Mutual labels:  slug
slugify
A Go slugify application that handles string
Stars: ✭ 31 (-99.46%)
Mutual labels:  slug
Dashify
Convert a camelcase or space-separated string to a dash-separated string.
Stars: ✭ 71 (-98.77%)
Mutual labels:  slug
Translug
中文的 url slug 支持
Stars: ✭ 145 (-97.49%)
Mutual labels:  slug
mongoose-slug-updater
Schema-based slug plugin for Mongoose - single/compound - unique over collection/group - nested docs/arrays - relative/abs paths - sync on change: create/save/update/updateOne/updateMany/findOneAndUpdate tracked - $set operator - counter/shortId
Stars: ✭ 37 (-99.36%)
Mutual labels:  slug
Slugify Cli
Slugify a string
Stars: ✭ 49 (-99.15%)
Mutual labels:  slug
Slug
URL-friendly slugify with multiple languages support.
Stars: ✭ 632 (-89.04%)
Mutual labels:  slug
Slugger
A Slugger for elixir.
Stars: ✭ 149 (-97.42%)
Mutual labels:  slug
awesome
🎉 An Open Microservice for "awesome" slugs.
Stars: ✭ 25 (-99.57%)
Mutual labels:  slug
Github Slug Action
GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow
Stars: ✭ 96 (-98.34%)
Mutual labels:  slug
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (-97.64%)
Mutual labels:  slug
mongoose-slug-plugin
Slugs for Mongoose with history and i18n support (uses speakingurl by default, but you can use any slug library such as limax, slugify, mollusc, or slugme)
Stars: ✭ 21 (-99.64%)
Mutual labels:  slug
Sluggish
Toy CPU and GPU implementations of the Slug rendering algorithm
Stars: ✭ 70 (-98.79%)
Mutual labels:  slug
Eloquent Sluggable
Easy creation of slugs for your Eloquent models in Laravel
Stars: ✭ 3,321 (-42.41%)
Mutual labels:  slug
Speakingurl
Generate a slug – transliteration with a lot of options
Stars: ✭ 1,056 (-81.69%)
Mutual labels:  slug
SlugGenerator
Slug generator for .net
Stars: ✭ 26 (-99.55%)
Mutual labels:  slug
Urlify
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.
Stars: ✭ 633 (-89.02%)
Mutual labels:  slug
Limax
Node.js module to generate URL slugs. Another one? This one cares about i18n and transliterates non-Latin scripts to conform to the RFC3986 standard. Mostly API-compatible with similar modules.
Stars: ✭ 423 (-92.67%)
Mutual labels:  slug
github-env-vars-action
🚀 GitHub Action for Environment Variables
Stars: ✭ 129 (-97.76%)
Mutual labels:  slug

Build Status Code Climate Inline docs

FriendlyId

For the most complete, user-friendly documentation, see the FriendlyId Guide.

FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins for Active Record. It lets you create pretty URLs and work with human-friendly strings as if they were numeric ids.

With FriendlyId, it's easy to make your application use URLs like:

https://example.com/states/washington

instead of:

https://example.com/states/4323454

Getting Help

Ask questions on Stack Overflow using the "friendly-id" tag, and for bugs have a look at the bug section

FriendlyId Features

FriendlyId offers many advanced features, including:

  • slug history and versioning
  • i18n
  • scoped slugs
  • reserved words
  • custom slug generators

Usage

Add this line to your application's Gemfile:

gem 'friendly_id', '~> 5.4.0'

Note: You MUST use 5.0.0 or greater for Rails 4.0+.

And then execute:

bundle install

Add a slug column to the desired table (e.g. Users)

rails g migration AddSlugToUsers slug:uniq

Generate the friendly configuration file and a new migration

rails generate friendly_id

Note: You can delete the CreateFriendlyIdSlugs migration if you won't use the slug history feature. (Read more)

Run the migration scripts

rails db:migrate

Edit the app/models/user.rb file as the following:

class User < ApplicationRecord
  extend FriendlyId
  friendly_id :name, use: :slugged
end

Edit the app/controllers/users_controller.rb file and replace User.find by User.friendly.find

class UserController < ApplicationController
  def show
    @user = User.friendly.find(params[:id])
  end
end

Now when you create a new user like the following:

User.create! name: "Joe Schmoe"

You can then access the user show page using the URL http://localhost:3000/users/joe-schmoe.

If you're adding FriendlyId to an existing app and need to generate slugs for existing users, do this from the console, runner, or add a Rake task:

User.find_each(&:save)

Bugs

Please report them on the Github issue tracker for this project.

If you have a bug to report, please include the following information:

  • Version information for FriendlyId, Rails and Ruby.
  • Full stack trace and error message (if you have them).
  • Any snippets of relevant model, view or controller code that shows how you are using FriendlyId.

If you are able to, it helps even more if you can fork FriendlyId on Github, and add a test that reproduces the error you are experiencing.

For more inspiration on how to report bugs, please see this article.

Thanks and Credits

FriendlyId was originally created by Norman Clarke and Adrian Mugnolo, with significant help early in its life by Emilio Tagua. It is now maintained by Norman Clarke and Philip Arndt.

We're deeply grateful for the generous contributions over the years from many volunteers.

License

Copyright (c) 2008-2020 Norman Clarke and contributors, released under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].