Richard Peck
Richard Peck

Reputation: 76774

friendly_id_slugs Table

Working on another deployment & found that rails generate friendly_id (as recommended by the Friendly_Id Documentation creates a new table called friendly_id_slugs - is this right or legacy?

Upvotes: 1

Views: 807

Answers (1)

Richard Peck
Richard Peck

Reputation: 76774

From the documentation:

FriendlyId's History module adds the ability to store a log of a model's slugs, so that when its friendly id changes, it's still possible to perform finds by the old id.

The primary use case for this is avoiding broken URLs.


Setup

In order to use this module, you must add a table to your database schema to store the slug records. FriendlyId provides a generator for this purpose:

rails generate friendly_id rake db:migrate This will add a table named friendly_id_slugs, used by the FriendlyId::Slug model.

Upvotes: 2

Related Questions