Class: Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/page.rb

Constant Summary collapse

TEMPLATES =
I18n.t('cms.admin.pages.templates').collect{|k,v| v}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_from_path(path) ⇒ Object



26
27
28
29
# File 'app/models/page.rb', line 26

def self.find_from_path(path)
  path = path.join("/")
  page = path.blank? ? Page.home_page : find_by_path(path)
end

.home_pageObject



31
32
33
# File 'app/models/page.rb', line 31

def self.home_page
  Page.find_by_slug('home')
end

Instance Method Details

#destroyObject



35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/page.rb', line 35

def destroy
  if self == Page.home_page
    self.errors.add_to_base I18n.t('cms.admin.pages.error_delete_home')
    return
  end
  unless self.children.empty?
    self.errors.add_to_base I18n.t('cms.admin.pages.error_delete_children')
    return
  end
  super
end