Class: PageStructureMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/site/04_page_structure.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



65
66
67
# File 'lib/migrations/site/04_page_structure.rb', line 65

def self.down(site)
  site.pages.all.each(&:destroy)
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/migrations/site/04_page_structure.rb', line 2

def self.up(site)
  # remove the default home page
  home = site.pages.where(path: '/').first
  home.destroy
  
  # home redirects to sites
  home = site.redirect_pages.new
  home.title = 'Home'
  home.url = '/sites'
  home.save
  
  # sites
  sites = site.sites_pages.new
  sites.title = 'Sites'
  sites.parent = home
  sites.show_record_layout = 'site'
  sites.save
  
  # remotes
  remotes = site.remotes_pages.new
  remotes.title = 'Remotes'
  remotes.parent = home
  remotes.show_record_layout = 'remote'
  remotes.save
  
  # default user
  default_user = site.record_proxy_pages.new
  default_user.title = 'Default User'
  default_user.parent = home
  default_user.record_model = site.default_users
  default_user.page_layout = 'default_user'
  default_user.after_update_page = default_user
  default_user.save
  
  # second setup step (done first because the first step refns this)
  setup_two = site.pages.new
  setup_two.title = 'Setup Remote'
  setup_two.parent = home
  setup_two.page_layout = 'setup_remote'
  setup_two.save
  
  # initial setup
  setup = site.pages.new
  setup.title = 'Setup'
  setup.parent = home
  setup.page_layout = 'setup'
  setup.save
  
  # menu
  nav = site.menus.new
  nav.name = 'nav'
  nav.root = home
  s1 = nav.exceptions.new
  s1.page = setup
  s1.show = false
  s1.save
  s2 = nav.exceptions.new
  s2.page = setup_two
  s2.show = false
  s2.save
  nav.save
end