Sha256: 73d6a09ca0dfd2e5b08898d3a21b3894e3b05c4fe534857609675cf7f96b5421

Contents?: true

Size: 768 Bytes

Versions: 14

Compression:

Stored size: 768 Bytes

Contents

module Cmor::Cms
  class Page < ActiveRecord::Base
    # add shared behaviour for database backed templates
    include Cmor::Cms::DatabaseTemplate

    # associations
    has_many :navigation_items,
             dependent: :nullify
    has_many :content_blocks,
             dependent: :destroy,
             inverse_of: :page

    accepts_nested_attributes_for :content_blocks, allow_destroy: true

    # publishing
    include ActsAsPublished::ActiveRecord
    acts_as_published

    # callbacks
    after_save :touch_navigation_items

    # validations
    validates :title, presence: true

    def home_page?
      pathname == '/' && basename == 'home'
    end

    def touch_navigation_items
      navigation_items.map(&:update_url_form_page!)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cmor_cms-0.0.57.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.56.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.55.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.54.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.53.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.52.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.51.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.50.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.49.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.48.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.45.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.44.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.43.pre app/models/cmor/cms/page.rb
cmor_cms-0.0.42.pre app/models/cmor/cms/page.rb