Sha256: 2f2ca6f8265d0af5d2850ca68cc8530f3bc9920447c3ad2b47bcec1923f17450
Contents?: true
Size: 717 Bytes
Versions: 11
Compression:
Stored size: 717 Bytes
Contents
class Pulitzer::PostType < ActiveRecord::Base enum kind: [ :template, :partial ] has_many :post_type_versions, dependent: :destroy has_one :published_type_version, -> { where(status: 'published') }, class_name: 'PostTypeVersion' has_many :preview_type_versions, -> { where(status: 'prevew') }, class_name: 'PostTypeVersion' scope :templates, -> { where(kind: Pulitzer::PostType.kinds[:template])} scope :partials, -> { where(kind: Pulitzer::PostType.kinds[:partial])} validates :name, :kind, presence: true validates :plural, :inclusion => { :in => [true, false] } def self.named(label) self.find_by(name: label) end def published_type_version_id published_type_version&.id end end
Version data entries
11 entries across 11 versions & 1 rubygems