Class: PageDecorator
Instance Method Summary
collapse
collection_decorator_class
Instance Method Details
#options_for_parents ⇒ Object
4
5
6
7
8
|
# File 'app/decorators/page_decorator.rb', line 4
def options_for_parents
Page.flat_tree.map do |p|
["#{'-' * p.depth} #{p.description}".strip, p.id]
end
end
|
#path(locale: I18n.locale, options: {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/decorators/page_decorator.rb', line 10
def path(locale: I18n.locale, options: {})
return h.send(route, options) if route.present?
slugs = []
parents.each do |p|
if p.route.present?
slugs << h.send(p.route, options)
return slugs.reverse.join('/')
else
slugs << p.seo(locale).slug
end
end
"/#{locale}/#{slugs.reverse.join('/')}"
end
|
#url(locale: I18n.locale, options: {}) ⇒ Object
27
28
29
30
31
32
33
|
# File 'app/decorators/page_decorator.rb', line 27
def url(locale: I18n.locale, options: {})
prefix = Rails.configuration.force_ssl ? 'https://' : 'http://'
host = Udongo.config.base.host
params = { locale: locale, options: options }
"#{prefix}#{host}#{path(params)}"
end
|