Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ActiveRecord plugin for automatically converting fields to permalinks.
Ruby
branch: master

This branch is 29 commits ahead, 1 commit behind technoweenie:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
test
.gitignore
Gemfile
README.md
Rakefile
permalink_fu.gemspec

README.md

PermalinkFu

ActiveRecord plugin for creating permalinks

Based on https://github.com/technoweenie/permalink_fu

class Article < ActiveRecord::Base
  has_permalink attr_names, permalink_field, options
end

Allowed options:

  • :if
  • :unless
  • :unique - true by default
  • :scope - skipped when :unique is set to false
  • :update - false by default

Usage examples

Stores permalink form of title to the permalink attribute:

has_permalink :title

Stores a permalink form of "#{category}-#{title}" to the permalink attribute:

has_permalink  [:category, :title]

Stores permalink form of category to the category_permalink attribute:

has_permalink :category, :category_permalink

Extend the scope within the parmalink should be unique:

has_permalink :title, :scope => :blog_id

Don't care if permalink in not unique:

has_permalink :title, :unique => false

Update the permalink every time the attribute(s) change:

has_permalink :title, :update => true
Something went wrong with that request. Please try again.