Skip to content

ActiveRecord plugin for automatically converting fields to permalinks.

Notifications You must be signed in to change notification settings

knapo/permalink_fu

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

ActiveRecord plugin for automatically converting fields to permalinks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%