Skip to content

Instantly share code, notes, and snippets.

@kylev
Created September 22, 2011 22:34
Show Gist options
  • Select an option

  • Save kylev/1236237 to your computer and use it in GitHub Desktop.

Select an option

Save kylev/1236237 to your computer and use it in GitHub Desktop.
Simple rake example for generating the configs a new developer will need to start up their environment.
DATABASE_YAML = <<-YML
defaults: &defaults
adapter: mysql2
username: root
password:
host: localhost
port: 3306
development:
<<: *defaults
database: foo_development
test:
<<: *defaults
database: foo_test
YML
MONGOID_YAML = <<-YML
development:
host: localhost
database: foo_development
test:
host: localhost
database: foo_test
YML
namespace :dev do
namespace :config do
def write_config(path, content)
File.open(Rails.root.join('config', path), 'w') do |f|
f.write content
end
end
desc "Write a developer/testing database.yml"
task :database => :environment do
write_config('database.yml', DATABASE_YAML)
end
desc "Write a developer/testing mongoid.yml"
task :mongoid => :environment do
write_config('mongoid.yml', MONGOID_YAML)
end
end
desc "Write config files for a developer environment."
task :config => [:"config:database", :"config:mongoid"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment