Class: MenuModelMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/yodel/14_menu_model.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



17
18
19
# File 'lib/migrations/yodel/14_menu_model.rb', line 17

def self.down(site)
  site.menus.destroy
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/migrations/yodel/14_menu_model.rb', line 2

def self.up(site)
  site.records.create_model :menu do |menus|
    add_one   :root, model: :page, validations: {required: {}}
    add_field :include_root, :boolean, default: false
    add_field :include_all_children, :boolean, default: true
    add_field :depth, :integer, default: 0, validations: {required: {}}
    add_embed_many :exceptions do
      add_one   :page
      add_field :show, :boolean, default: false
      add_field :depth, :integer, default: 0, validations: {required: {}}
    end
    menus.record_class_name = 'Menu'
  end
end