Ruby on Rails:我如何为postgresql编辑database.yml?

shi*_*bly 45 ruby database postgresql ruby-on-rails ruby-on-rails-3

rails new app =>

当前的database.yml就像是=>

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# 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: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
Run Code Online (Sandbox Code Playgroud)

我需要为postgresql数据库编辑这个.

我怎样才能做到这一点 ?

Zab*_*bba 96

只是:

development:
  adapter: postgresql
  encoding: unicode
  database: blog_development
  pool: 5
  username: blog
  password:
  host: localhost
Run Code Online (Sandbox Code Playgroud)

来源:配置Rails应用程序


LHH*_*LHH 14

development:
  adapter: postgresql
  encoding: utf8
  database: name
  username: hading
  password: my_db_password
  pool: 5 # not mandatory
  timeout: 5000 # not mandatory
  host: localhost
  port: your postgresql port number (5432 or 5433)
Run Code Online (Sandbox Code Playgroud)


tes*_*ssi 6

正如扎巴说的那样

development:
  adapter: postgresql
  encoding: unicode
  database: blog_development
  pool: 5
  username: blog
  password:
Run Code Online (Sandbox Code Playgroud)

配置Rails应用程序中所述.但是你可能想要一个额外的min_messages: WARNING,以消除postgresql在迁移过程中给你的令人讨厌的NOTICE消息.所以我的database.yml条目看起来像这样

development:
  adapter: postgresql
  encoding: unicode
  database: blog_development
  pool: 5
  username: blog
  password:
  min_messages: WARNING
Run Code Online (Sandbox Code Playgroud)


Don*_*lie 5

您可能对使用 postgres 默认生成新应用程序感兴趣:

rails new myapp --database=postgresql
Run Code Online (Sandbox Code Playgroud)

如此处所述:https : //devcenter.heroku.com/articles/getting-started-with-rails4