Sha256: 08a34ffe5398208035cc211a7c37dcafe02572abe6b85919c2fe54c692eb829a

Contents?: true

Size: 872 Bytes

Versions: 1

Compression:

Stored size: 872 Bytes

Contents

module Spotlight
  class FeaturePage < Spotlight::Page
    extend FriendlyId
    friendly_id :title, use: [:slugged,:scoped,:finders,:history], scope: :exhibit

    has_many   :child_pages, class_name: "Spotlight::FeaturePage", inverse_of: :parent_page, foreign_key: "parent_page_id"
    belongs_to :parent_page, class_name: "Spotlight::FeaturePage"

    accepts_nested_attributes_for :child_pages
    
    belongs_to :thumbnail, class_name: "Spotlight::FeaturedImage", dependent: :destroy
    accepts_nested_attributes_for :thumbnail, update_only: true

    before_validation unless: :top_level_page? do
      self.exhibit = top_level_page_or_self.exhibit
    end

    def display_sidebar?
      child_pages.published.present? || self.display_sidebar
    end

    def thumbnail_image_url
      thumbnail.image.thumb.url if thumbnail and thumbnail.image
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 app/models/spotlight/feature_page.rb