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

hlcfan · October 16, 2012 · Last by hlcfan replied at October 16, 2012 · 2300 hits

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

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

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
You need to Sign in before reply, if you don't have an account, please Sign up first.