De nieuwste versies van Mongoid ondersteunen dit. Zie de documenten .
Fragmenten:
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
In uw model:
class Business
include Mongoid::Document
set_database :secondary
end