I am using Rails 3 and Mongoid gem. But I need to fill a combobox with the list of mongodb databases. In mongodb shell we can list databases with "show dbs" command. Also there is getDBNameList() and db.getCollectionNames() commands in mongodb drivers. But I could not figure out how to use these commands from a ruby on rails app.
Also I wonder; if I can get databases and collections list with using mongoid gem. Because I am sure that I had read that mongoid supports using more than one database, but I think it was model dependent.
So what do you think; is there any solution or I have to use mongo-ruby-driver gem, not mongoid.
You can do the following using the mongo ruby driver:
Using Java driver you can list the database names using the following
It would be easier to get the Mongo::DB out of the Mongoid config:
A short version.
In mongoid 3
I usually extract the names as follows: