14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/models/dynamic_content/page.rb', line 14
def self.load page
current = self.includes(:sections).find_by_slug(page)
return {} if current.nil?
results = {
id: current.id,
title: current.title,
keywords: current.keywords.try(:join, ', '),
description: current.description
}
sections_content = current.sections sections_content = sections_content + Section.where(on_application: true) if page == 'application'
sections_content.each do |section|
results[section.slug.to_sym] = {
name: section.name
}
section.contents.each do |content|
results[section.slug.to_sym][content.slug.to_sym] = content.get_content
end
end
return results
end
|