Class: Page
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Content
#author_name, #body_html, #publish!, #published=, #published?, #status, #status=
Class Method Details
.root ⇒ Object
15
16
17
|
# File 'app/models/page.rb', line 15
def self.root
roots.first
end
|
Instance Method Details
#ancestors ⇒ Object
24
25
26
27
28
|
# File 'app/models/page.rb', line 24
def ancestors
node, nodes = self, []
nodes << node = node.parent while node.parent
nodes
end
|
#root? ⇒ Boolean
Also known as:
homepage?
19
20
21
|
# File 'app/models/page.rb', line 19
def root?
self == Page.root || Page.count == 0 && new_record?
end
|
#url ⇒ Object
30
31
32
33
34
|
# File 'app/models/page.rb', line 30
def url
links = (ancestors.map(&:permalink) << permalink).delete_if(&:blank?)
"/#{links.join('/')}"
end
|