Created
January 14, 2013 19:32
-
-
Save revans/4532640 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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