gem mongoid 首先在 mongoid.yml 文件里添加几行:
default:
database: china_scope
hosts:
- localhost:27017
options:
# Change the default write concern. (default = { w: 1 })
# write:
# w: 1
name_you_set:
database: db_name
hosts:
- localhost:27017
其次在 model 里添加一行: store_in database:"name_you_set" store_in collection: "collection_name"