zfj.rails 发表于 2013-1-30 01:32:55

【config\database.yml】之简写

base: &baseadapter: postgresqlencoding: UTF8host: localhostusername: xxxpassword: xxxpool: 5timeout: 5000development: &development<<: *basedatabase: app_developmentproduction: &production<<: *basedatabase: app_productiontest: &test<<: *basedatabase: app_test

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

另外,补充下哈。

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

base: &base......test: &test<<: *basedatabase: app_testanotherdb: &anotherdb<<: *basedatabase: anotherdb

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

class Contact < ActiveRecord::Baseestablish_connection :anotherdb......end
页: [1]
查看完整版本: 【config\database.yml】之简写