82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/cms/concerns/can_be_addressable.rb', line 82
def assign_parent_if_needed
unless parent || parent_id
new_parent = Cms::Section.with_path(self.class.path).first
unless new_parent
logger.warn "Creating default section for #{self.try(:display_name)} in #{self.class.path}."
section_attributes = {:name => self.class.name.demodulize.pluralize,
:path => self.class.path,
:hidden => true,
allow_groups: :all}
section_parent = Cms::Section.root.first
if section_parent
section_attributes[:parent] = section_parent
end
new_parent = Cms::Section.create!(section_attributes)
end
self.parent_id = new_parent.id
end
end
|