You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had to figure this out for myself as well, since the code is a bit less than clear on how to do this, but it is possible, by giving the File and Chunk model a store_in hash.
For database-only changes, use store_in database: "files_database" on both models. Mongoid 3/4 use named sessions (store_in session: :gridfs). This is shared model configuration, not a per-request switch. #89 documents the existing configuration API.
Activity
syntruth commentedon Apr 3, 2018
I had to figure this out for myself as well, since the code is a bit less than clear on how to do this, but it is possible, by giving the File and Chunk model a
store_inhash.This can then be confirmed with:
In my apps file model (in this case, for ActiveDirectory user photos), I have a convenience memoized set up method:
So far, that seems to work, allowing me to store those files in a single database, but access them from 3 separate web-apps.
Expose GridFS queries and document storage configuration
dblock commentedon Oct 18, 2026
Configure a named Mongoid client with the separate hosts/database, then select it on BOTH GridFS models during application initialization:
For database-only changes, use
store_in database: "files_database"on both models. Mongoid 3/4 use named sessions (store_in session: :gridfs). This is shared model configuration, not a per-request switch. #89 documents the existing configuration API.Posted by an AI on behalf of @dblock.
Expose GridFS queries and document storage configuration
Expose GridFS queries and document storage configuration