Skip to content

Commit 6bf50b4

Browse files
committed
Allow clearing the root site content
1 parent 8794ba8 commit 6bf50b4

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

app/services/clear_cms_content_service.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ def initialize(convention:)
99
private
1010

1111
def inner_call
12-
convention.update!(root_page: nil, default_layout: nil, user_con_profile_form: nil)
13-
convention.cms_navigation_items.destroy_all
14-
convention.pages.destroy_all
15-
convention.cms_partials.destroy_all
16-
convention.cms_layouts.destroy_all
17-
convention.cms_files.destroy_all
18-
convention.forms.destroy_all
12+
cms_parent.update!(root_page: nil, default_layout: nil, user_con_profile_form: nil)
13+
cms_parent.cms_navigation_items.destroy_all
14+
cms_parent.pages.destroy_all
15+
cms_parent.cms_partials.destroy_all
16+
cms_parent.cms_layouts.destroy_all
17+
cms_parent.cms_files.destroy_all
18+
cms_parent.forms.destroy_all
1919

2020
success
2121
end
22+
23+
def cms_parent
24+
@cms_parent ||= convention || RootSite.instance
25+
end
2226
end

0 commit comments

Comments
 (0)