Sha256: 9cdc23bdfbfcfdfce654be53e209ee1a33abcfaa61a907309ca1804f6ad06b7b
Contents?: true
Size: 984 Bytes
Versions: 17
Compression:
Stored size: 984 Bytes
Contents
module PushType class Taxonomy < ActiveRecord::Base include PushType::Templatable include PushType::Unexposable acts_as_tree name_column: 'slug', order: 'sort_order', dependent: :destroy validates :title, presence: true, uniqueness: { scope: :parent_id } validates :slug, presence: true, uniqueness: { scope: :parent_id } class << self def title @title ||= name.underscore.humanize.pluralize end def base_slug(*args) if args.present? @base_slug = args.first else ( @base_slug || name ).to_s.underscore end end end def base_slug self.class.base_slug end def permalink(with_base_sug = false) @permalink ||= self_and_ancestors.map(&:slug).reverse (with_base_sug ? @permalink.unshift(base_slug) : @permalink).join('/') end def full_permalink permalink(true) end def exposed? self.class.exposed? end end end
Version data entries
17 entries across 17 versions & 1 rubygems