Sha256: aff8b4915399dea7c85d13708b785569b83d0096fc64bc03078548c777271867
Contents?: true
Size: 841 Bytes
Versions: 1
Compression:
Stored size: 841 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 def most_recent_published_post_type_version post_type_versions&.published&.order(version_number: :desc)&.first end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pulitzer-0.15.12 | app/models/pulitzer/post_type.rb |