Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denniscastro/481780 to your computer and use it in GitHub Desktop.
Save denniscastro/481780 to your computer and use it in GitHub Desktop.
FriendlyId Rake Tasks
FriendlyId provides several tasks to help maintain your application.
Generating New Slugs For the First Time
friendly_id:make_slugs MODEL=<model name>
Use this task to generate slugs after installing FriendlyId in a new application.
Regenerating Slugs
friendly_id:redo_slugs MODEL=<model name>
Use this task to regenerate slugs after making any changes to your model’s FriendlyId configuration options that affect slug generation. For example, if you introduce a cached_slug column or change the :seqence_separator.
Deleting Old Slugs
rake friendly_id:remove_old_slugs MODEL=<model name> DAYS=<days>
Use this task if you wish to delete expired slugs; manually or perhaps via cron. If you don’t specify the days option, the default is to remove unused slugs older than 45 days.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment