Sha256: c66bbe0247b19e0361ef259418ab42c22128c364b7dc8441f97a7bca91fe69d4

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

class Ecm::Cms::Page < ActiveRecord::Base
  self.table_name = 'ecm_cms_pages'

  # add shared behaviour for database backed templates
  include Ecm::Cms::DatabaseTemplate

  # associations
  has_many :ecm_cms_navigation_items,
           :class_name => 'Ecm::Cms::NavigationItem',
           :dependent => :nullify,
           :foreign_key => 'ecm_cms_page_id'

  # attributes
  attr_accessible :basename,
                  :body,
                  :ecm_cms_folder_id,
                  :ecm_cms_navigation_item_ids,
                  :format,
                  :handler,
                  :layout,
                  :locale,
                  :meta_description,
                  :pathname,
                  :title

  # 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? 
    return self.pathname == '/' && self.basename == 'home'
  end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ecm_cms-0.0.13.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.11.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.10.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.8.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.7.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.6.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.5.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.4.pre app/models/ecm/cms/page.rb
ecm_cms-0.0.3.pre app/models/ecm/cms/page.rb