Skip to content

Instantly share code, notes, and snippets.

@maxy
Created September 19, 2014 02:29
Show Gist options
  • Save maxy/e1d8d6ab86278a1da90a to your computer and use it in GitHub Desktop.
Save maxy/e1d8d6ab86278a1da90a to your computer and use it in GitHub Desktop.
database.ymlをERBでテンプレート解析後、設定ファイルを読み込む
development:
adapter: postgres
database: DATABASE_NAME
pool: 5
timeout: 5000
username: <%= ENV['PG_USER'] || 'postgres' %>
password: <%= ENV['PG_PASSWORD'] || '' %>
host: <%= ENV['PG_HOST'] || 'localhost' %>
port: <%= ENV['PG_PORT'] || 5432 %>
encoding: utf8
env = ENV['ENVIRONMENT'] || 'development'
YAML.load(ERB.new(File.read('database.yml')).result)[env]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment