Sha256: e0e57ea9bfc7fca8af3705611b3a09e34ecfe8e12ff1761c5f90a3c891629402
Contents?: true
Size: 1.29 KB
Versions: 13
Compression:
Stored size: 1.29 KB
Contents
class Page < ActiveRecord::Base has_paper_trail has_friendly_id :title, :use_slug => true acts_as_indexed :fields => [:title, :body, :area_1, :area_2, :meta_keywords, :meta_description, :nav_label] 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) before_save :set_nav_label 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 i = 0 until page.parent.nil? || page.parent_id == page.id || i > 10 i += 1 page = page.parent title += " » #{page.title}".html_safe end title.html_safe end def parents parents = [self] page = self i = 0 until page.nil? || page.parent_id == page.id || i > 10 i += 1 page = page.parent parents << page unless page.nil? end parents.reverse! end private def set_nav_label self.nav_label = self.title if self.nav_label.nil? || self.nav_label.empty? end end
Version data entries
13 entries across 13 versions & 1 rubygems