Sha256: a0213d21c0ff9b7e9d700cf77e21f2e116fc9158535bb48b798a5e1fa701e0ae
Contents?: true
Size: 786 Bytes
Versions: 8
Compression:
Stored size: 786 Bytes
Contents
require "friendly_id" module Adva module HasPermalink def self.included(base) base.extend ClassMethods end module ClassMethods def has_permalink column, options={} extend FriendlyId friendly_id column do |config| config.use :slugged, :finders if options[:scope] config.use :scoped config.scope = options[:scope] end config.slug_column = options[:url_attribute] end self.class_eval do def should_generate_new_friendly_id? permalink.blank? end end define_method :"#{options[:url_attribute]}=" do |value| value = value.parameterize if value super value end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems