我目前有一个Rails项目,我将其部署到使用postgres数据库的生产服务器上。我在Windows中开发我的rails项目,这意味着,如果要在本地进行测试,则必须将database.yml文件中的所有数据库从postgres更改为sqlite3(因为将Windows设置为运行postgres服务器似乎是痛苦)。
我想做的是格式化我的database.yml像这样:
development:
adapter: postgresql
encoding: utf8
database: <%= begin IO.read("/home/www-data/.db/.dev_name") rescue "" end %>
pool: 5
username: <%= begin IO.read("/home/www-data/.db/.user") rescue "" end %>
password: <%= begin IO.read("/home/www-data/.db/.pass") rescue "" end %>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
encoding: …Run Code Online (Sandbox Code Playgroud) database sqlite ruby-on-rails ruby-on-rails-3 rails-postgresql