De nyeste versioner af Mongoid understøtter dette. Se dokumenterne .
Uddrag:
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
I din model:
class Business
include Mongoid::Document
set_database :secondary
end