Sha256: fb18f0750e4c97b7021d57a60dc41e1874fbb71b12b673cea6bc4b4c2cdedcec

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

puts "[soapbox] main page model loaded"
class Page < ActiveRecord::Base
  
  has_paper_trail
  acts_as_indexed :fields => [:title, :body, :area_1, :area_2, :meta_keywords, :meta_description, :nav_label]  
  has_friendly_id :title, :use_slug => true
  
  acts_as_tree :order => "position"
  
  has_many :menu_items, :as => :menuable, :dependent => :destroy
  has_many :galleries, :as => :galleriable
  
  default_scope order("parent_id, position")
  scope :published, where("publish = ? OR (release_at > ? AND expire_at < ?) ", true, Time.zone.now, Time.zone.now)
  
  include Soapbox::Page if File.exists? "app/models/soapbox/page.rb"
  
  def self.homepage
    self.where("homepage=?",true).first
  end
  
  def title_bread_crumb
    title = self.title
    page = self
    until page.parent.nil?
      page = page.parent
      title += " &raquo; #{page.title}".html_safe
    end
    title.html_safe
  end
  
  def parents
    parents = [self]
    page = self
    until page.nil?
      page = page.parent
      parents << page unless page.nil?
    end
    parents.reverse!
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soapbox-0.1.7 app/models/page.rb
soapbox-0.1.3 app/models/page.rb
soapbox-0.1.2 app/models/page.rb
soapbox-0.1.1 app/models/page.rb