Най-новите версии на Mongoid поддържат това. Вижте документите .
Фрагменти:
config/mongoid.yml:
defaults: &defaults
host: localhost
slaves:
- host: localhost
port: 27018
- host: localhost
port: 27019
databases:
secondary:
database: secondary_database
host: localhost
port: 27020
slaves:
- host: localhost
port: 27021
- host: localhost
port: 27022
Във вашия модел:
class Business
include Mongoid::Document
set_database :secondary
end