Nejnovější verze Mongoidu to podporují. Viz dokumenty .
Úryvky:
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
Ve vašem modelu:
class Business
include Mongoid::Document
set_database :secondary
end