Les dernières versions de Mongoid prennent en charge cela. Voir la documentation .
Extraits :
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
Dans votre modèle :
class Business
include Mongoid::Document
set_database :secondary
end