ruby-on-railsmongodbmongoidmongodb-rubymongoid3

How to programmatically get the current database Mongoid is writing to?


I am talking to multiple databases using Mongoid.override_database("database_name") using Mongoid with rails. How do I find the current database programmatically?

Mongoid docs on sessions: http://mongoid.org/en/moped/docs/driver.html define methods to override database but do not define a way to get the current database in use.


Solution

  • Got it!

    Mongoid.default_session.options[:database]