class Rsg::Generators::Orm::ActiveRecordGenerator

Constants

SUPPORTED_DBS

Public Class Methods

source_paths() click to toggle source
# File lib/rsg/generators/orm/active_record_generator.rb, line 12
def self.source_paths
  @__source_paths ||= [
    Rails::Generators::AppGenerator.source_root,
    Pathname.new(__FILE__).dirname.join("templates").expand_path
  ]
end
source_root() click to toggle source
# File lib/rsg/generators/orm/active_record_generator.rb, line 8
def self.source_root
  Pathname.new(__FILE__).dirname.join("templates").expand_path
end

Public Instance Methods

banner() click to toggle source
configure_driver() click to toggle source
# File lib/rsg/generators/orm/active_record_generator.rb, line 27
def configure_driver
  database ||= options.fetch(:database) { ask("Which database you'd like to use?", limited_to: SUPPORTED_DBS, default: "sqlite3") }
  # From the core rails template
  template "config/databases/#{database}.yml", "config/database.yml"

  name, version = gem_for_database(database)
  append_gem name, version: version
end
enable_active_record() click to toggle source
# File lib/rsg/generators/orm/active_record_generator.rb, line 23
def enable_active_record
  enable_railtie "active_record"
end
migrate() click to toggle source
# File lib/rsg/generators/orm/active_record_generator.rb, line 42
def migrate
  if options.key?(:auto_migrate)
    rake "db:create db:migrate" if options[:auto_migrate]
    return
  end

  rake "db:create db:migrate" unless no?("Would you like to create the database schema?")
end
write_db_sample() click to toggle source
# File lib/rsg/generators/orm/active_record_generator.rb, line 36
def write_db_sample
  copy_file "db.rake", "lib/tasks/db.rake"
  copy_file "seeds.rb", "db/seeds.rb"
  copy_file "samples.rb", "db/samples.rb"
end