【config\database.yml】之简写

base: &base
  adapter: postgresql
  encoding: UTF8
  host: localhost
  username: xxx
  password: xxx
  pool: 5
  timeout: 5000

development: &development
  <<: *base
  database: app_development

production: &production
  <<: *base
  database: app_production

test: &test
  <<: *base
  database: app_test


如有不同之处,请自行替换。

另外,补充下哈。

如项目打算用到多个数据库,也可在些配置文件中配置。如:

base: &base
...
...
test: &test
  <<: *base
  database: app_test

anotherdb: &anotherdb
  <<: *base
  database: anotherdb


在要用到的Model中这样调用:

class Contact < ActiveRecord::Base
  establish_connection :anotherdb
  ...
  ...
end


你可能感兴趣的:(PostgreSQL,Ruby,ActiveRecord)