Class: Trek::Generators::Install::MenuNodeGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration, Helpers
Defined in:
lib/generators/trek/install/menu_node_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_menu_node_hierarchies_migration_fileObject



29
30
31
32
# File 'lib/generators/trek/install/menu_node_generator.rb', line 29

def copy_menu_node_hierarchies_migration_file
  rails_command "db:migrate" # `menu_nodes` table must exist
  generate "closure_tree:migration MenuNode"
end

#copy_migration_fileObject



21
22
23
24
25
26
27
# File 'lib/generators/trek/install/menu_node_generator.rb', line 21

def copy_migration_file
  return unless defined?(ActiveRecord)

  migration_template("migrations/menu_nodes.rb.erb",
    "db/migrate/trek_menu_nodes.rb",
    migration_class_name:)
end

#copy_modelObject



16
17
18
19
# File 'lib/generators/trek/install/menu_node_generator.rb', line 16

def copy_model
  template "models/menu_node.rb",
    "app/models/menu_node.rb"
end