Created
September 19, 2014 02:29
-
-
Save maxy/e1d8d6ab86278a1da90a to your computer and use it in GitHub Desktop.
database.ymlをERBでテンプレート解析後、設定ファイルを読み込む
This file contains 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
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 |
This file contains 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
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