Class: SimpleContentManagement::SimplePage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SimpleContentManagement::SimplePage
show all
- Includes:
- Breadcrumbs, ContentText
- Defined in:
- app/models/simple_content_management/simple_page.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#update_content_text, #update_content_text!
Class Method Details
.registered_content_pages ⇒ Object
63
64
65
|
# File 'app/models/simple_content_management/simple_page.rb', line 63
def registered_content_pages
@registered_content_pages ||= YAML.load_file File.join Rails.root, "config", "content_pages.yml"
end
|
Instance Method Details
#destroy ⇒ Object
50
51
52
|
# File 'app/models/simple_content_management/simple_page.rb', line 50
def destroy
update_attribute :deleted, true
end
|
#label ⇒ Object
54
55
56
|
# File 'app/models/simple_content_management/simple_page.rb', line 54
def label
title
end
|
#path_names ⇒ Object
46
47
48
|
# File 'app/models/simple_content_management/simple_page.rb', line 46
def path_names
new_record? ? simple_routes.map(&:path) : simple_routes.active.pluck("path")
end
|
#reconstruct_breadcrumbs ⇒ Object
58
59
60
|
# File 'app/models/simple_content_management/simple_page.rb', line 58
def reconstruct_breadcrumbs
self. = .first unless .present? || .first.nil?
end
|
13
14
15
|
# File 'app/models/simple_content_management/simple_page.rb', line 13
def
SimpleContentManagement::SimpleMenuItem.where(uri: path_names.map{ |path| "/#{path}.html" } + (path_names.include?("particulier") ? ["/"] : []))
end
|
#simple_routes_list ⇒ Object
17
18
19
|
# File 'app/models/simple_content_management/simple_page.rb', line 17
def simple_routes_list
path_names.join ","
end
|
#simple_routes_list=(routes_list) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/models/simple_content_management/simple_page.rb', line 21
def simple_routes_list=(routes_list)
path_names = routes_list.split ","
self.simple_routes.each do |simple_route|
if path_names.include? simple_route.path
path_names.delete simple_route.path
else
simple_route.destroy
end
end
if id.nil?
SimpleContentManagement::SimpleRoute.where(path: path_names, deleted: false).update_all deleted: true
else
SimpleContentManagement::SimpleRoute.where(path: path_names, deleted: false).where("simple_page_id <> ?", id).update_all deleted: true
end
path_names.each do |path_name|
self.simple_routes.build path: path_name
end
end
|