Sha256: fd8a6a2956ad75ace34eae9f770ab8503904978116377204bdb14edb1744de99

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

require "rails/generators"

module Multiverse
  module Generators
    class DbGenerator < Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      argument :name

      def create_initializer
        lower_name = name.underscore

        template "record.rb", "app/models/#{lower_name}_record.rb"

        append_to_file "config/database.yml" do
          "
#{name}_development:
  <<: *default
  database: #{lower_name}_development

#{name}_test:
  <<: *default
  database: #{lower_name}_test

#{name}_production:
  <<: *default
  url: <%= ENV['#{lower_name.upcase}_DATABASE_URL'] %>
"
        end

        empty_directory "db/#{lower_name}/migrate"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multiverse-0.0.1 lib/generators/multiverse/db_generator.rb