Class: LayeredStackRails::ScaffoldGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/layered_stack_rails/scaffold_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_model_fileObject



21
22
23
# File 'lib/generators/layered_stack_rails/scaffold_generator.rb', line 21

def create_model_file
  template "active_record/model/model.erb", File.join("app/models", "#{model_name}.rb")
end

#executeObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/layered_stack_rails/scaffold_generator.rb', line 9

def execute
  yaml_content = YAML.load_file(File.join("app.yml"))

  model_data = yaml_content["resources"][model_name]
  if model_data
    puts "Generating model #{model_name} with attributes: #{model_data["attributes"]}"
    generate_scaffold(model_name, model_data["attributes"], model_data["associations"])
  else
    puts "Model #{model_name} not found in app.yml"
  end
end