Sha256: 34b11f1306657eb6e65571346b0193730274471206664d25e79f9402d23363fe

Contents?: true

Size: 1.56 KB

Versions: 8

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

# Ads methods to ActiveRecord:Migration to create and manage database views in Rails
#
# exe/rag addons/scenic

self.local_template_path = File.dirname(__FILE__)

gac 'base rails 7 image created'

prepare_environment

after_bundle do
  force_copy
  
  create_db
  scaffolds
  setup_customizations
  migrate_db
end

def scaffolds
  add_scaffold('country', 'code', 'name')
  add_scaffold('monument', 'name', 'description', 'country:references')
  add_scaffold('visitor', 'name', 'monument:references')

  generate('scenic:model visitors_by_monument')
  generate('scenic:model individual_visitors_by_monument --materialized')

  directory "db/views"
end

def setup_customizations
  route("root 'home#index'")

  add_controller('home', 'index', 'visitors_by_monument', 'individual_visitors_by_monument', 'reseed', 'refresh_material_view')

  directory "app/controllers"
  directory "app/models"
  directory "app/views"
  template  'app/views/layouts/application.html.erb'        , 'app/views/layouts/application.html.erb'
  directory "app/services"
end

def create_db
  gsub_file('config/database.yml', '  encoding: unicode', db_development_settings)
  rails_command('db:environment:set RAILS_ENV=development')
  db(drop: true, create: true)
end

def migrate_db
  template  'db/seeds.rb'                                   , 'db/seeds.rb'

  db(migrate: true, seed: true)
end

def db_development_settings
  <<-'RUBY'
  encoding: unicode
  host: <%= ENV['DATABASE_HOST'] %>
  username: <%= ENV['DATABASE_USERNAME'] %>
  password: <%= ENV['DATABASE_PASSWORD'] %>
  RUBY
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails_app_generator-0.3.6 after_templates/addons/scenic/_.rb
rails_app_generator-0.3.5 after_templates/addons/scenic/_.rb
rails_app_generator-0.3.4 after_templates/addons/scenic/_.rb
rails_app_generator-0.3.3 after_templates/addons/scenic/_.rb
rails_app_generator-0.3.2 after_templates/addons/scenic/_.rb
rails_app_generator-0.3.1 after_templates/addons/scenic/_.rb
rails_app_generator-0.3.0 after_templates/addons/scenic/_.rb
rails_app_generator-0.2.43 after_templates/addons/scenic/_.rb