Skip to content

Instantly share code, notes, and snippets.

@revans
Created January 14, 2013 19:32
Show Gist options
  • Save revans/4532640 to your computer and use it in GitHub Desktop.
Save revans/4532640 to your computer and use it in GitHub Desktop.
require 'erb'
namespace :db do
namespace :generate do
desc "Generate a config/database.conf"
task :config do
db_example = Rails.root.join("config/database.yml.erb")
print "What is your password for your local database? (leave empty for no password): "
# get data
@user = `whoami`.chomp
@password = STDIN.noecho(&:gets).chomp
content = ERB.new(db_example.read).result
File.open(Rails.root.join("config/database.yml").to_s, "w") do |file|
file.write content
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment