Skip to content

Instantly share code, notes, and snippets.

@leather-s
Created June 24, 2018 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leather-s/d2245f285cacaf38d6ecd4fc12ba8a20 to your computer and use it in GitHub Desktop.
Save leather-s/d2245f285cacaf38d6ecd4fc12ba8a20 to your computer and use it in GitHub Desktop.
module RenoteDac
module Generators
class InstallGenerator < Rails::Generators::Base
# RenoteDac::Generators::InstallGenerator.source_root("lib/generators/renote_dac/templates")
source_root File.expand_path("../templates", __FILE__)
desc "This generator creates a renote_dac.rb initializer file at config/initializers"
def create_initializer_file
template "initializer.rb", "config/initializers/renote_dac.rb"
end
desc "This generator creates a @timestamp_create_emails.rb migration file at db/migrate"
def create_migrations
template 'create_emails.rb', "#{Time.now.strftime("%Y%m%d%H%M%S")}_create_emails.rb"
end
def create_database_yml
database_name = Rails.application.class.parent_name.underscore.gsub("_","-")
create_file('config/database.yml',
%{default: &default
adapter: "#{Settings.database.adapter}"
encoding: unicode
pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %>
prepared_statements: false
development:
<<: *default
database: #{database_name}_dev
production:
<<: *default
}
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment