Sha256: ac2d2786ea1a5e3f4e1e2e96d912588cb36ae4f5c8a9a373a5c367e794a6a55d

Contents?: true

Size: 1018 Bytes

Versions: 20

Compression:

Stored size: 1018 Bytes

Contents

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

    # associations
    has_many :ecm_cms_navigation_items,
             class_name: 'NavigationItem',
             dependent: :nullify,
             foreign_key: 'ecm_cms_page_id'
    has_many :ecm_cms_page_content_blocks,
             class_name: 'Ecm::Cms::Page::ContentBlock',
             dependent: :destroy,
             foreign_key: 'ecm_cms_page_id',
             inverse_of: :ecm_cms_page

    accepts_nested_attributes_for :ecm_cms_page_content_blocks, allow_destroy: true

    # callbacks
    after_save :touch_navigation_items # , :if => Proc.new { |page| page.locale_changed? || page.pathname_changed? || page.basename_changed? }

    # validations
    validates :title, presence: true

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ecm_cms2-5.1.2 app/models/ecm/cms/page.rb
ecm_cms2-5.1.1 app/models/ecm/cms/page.rb
ecm_cms2-5.1.0 app/models/ecm/cms/page.rb
ecm_cms2-5.0.0 app/models/ecm/cms/page.rb
ecm_cms2-4.1.1 app/models/ecm/cms/page.rb
ecm_cms2-4.1.0 app/models/ecm/cms/page.rb
ecm_cms2-4.0.1 app/models/ecm/cms/page.rb
ecm_cms2-4.0.0 app/models/ecm/cms/page.rb
ecm_cms2-3.0.3 app/models/ecm/cms/page.rb
ecm_cms2-3.0.2 app/models/ecm/cms/page.rb
ecm_cms2-3.0.1 app/models/ecm/cms/page.rb
ecm_cms2-3.0.0 app/models/ecm/cms/page.rb
ecm_cms2-2.1.4 app/models/ecm/cms/page.rb
ecm_cms2-2.1.3 app/models/ecm/cms/page.rb
ecm_cms2-2.1.2 app/models/ecm/cms/page.rb
ecm_cms2-2.1.1 app/models/ecm/cms/page.rb
ecm_cms2-2.1.0 app/models/ecm/cms/page.rb
ecm_cms2-2.0.4 app/models/ecm/cms/page.rb
ecm_cms2-2.0.3 app/models/ecm/cms/page.rb
ecm_cms2-2.0.2 app/models/ecm/cms/page.rb