Rails 如何在项目中指定另一个数据库?

hlcfan · 2012年10月16日 · 最后由 hlcfan 回复于 2012年10月16日 · 2300 次阅读

如何在项目中指定另一个数据库?

项目不止一个数据库,怎么指定另一个数据库?

model

class OrderRecord < ActiveRecord::Base
  establish_connection :db_name
end

database.yml

db_name:
  adapter: postgresql
  encoding: unicode
  database: xxx_development
  pool: 5
  # port: 54321
  # host: localhost
  host: 'xxx.xxx.xxx'
  username: xxxx
  password: none
需要 登录 后方可回复, 如果你还没有账号请 注册新账号