Sha256: 5b11e142695f122ff2bf0dae32db8fba029651045e5172e3a103b944c2dca7a0
Contents?: true
Size: 603 Bytes
Versions: 2
Compression:
Stored size: 603 Bytes
Contents
require "friendly_id" ActiveRecord::Base.class_eval do def self.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
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
adva_cms-0.0.1 | config/initializers/has_permalink.rb |
adva-0.0.1 | adva_cms/config/initializers/has_permalink.rb |