`
zfj.rails
  • 浏览: 45004 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

【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


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics