OPTIONS

Ruby MongoDB Driver

Ruby Driver 2.0 Released

For more information, see Announcing Ruby Driver 2.0, a Rewrite.

This is an overview of the available tools and suggested practices for using Ruby with MongoDB. To skip to more detailed discussion see:

For a list of external resources, see Ruby External Resources.

Ruby Driver

The MongoDB Ruby driver is the officially supported Ruby driver for MongoDB. It’s written in pure Ruby and is optimized for simplicity. It can be used on its own, but it also serves as the basis of several object mapping libraries, such as Mongoid.

Resources:

Compatibility

MongoDB Compatibility

The following compatibility table specifies the recommended version(s) of the MongoDB Ruby driver for use with a specific version of MongoDB.

The first column lists the driver version(s).

Ruby Driver MongoDB 2.4 MongoDB 2.6 MongoDB 3.0
2.0
1.12

For additional driver versions, see Ruby Driver MongoDB Compatibility Reference.

The driver does not support older versions of MongoDB.

Language Compatibility

The following compatibility table specifies the recommended version(s) of the MongoDB Ruby driver for use with a specific version of Ruby.

The first column lists the driver version(s).

Ruby Driver Ruby 1.8.7 Ruby 1.9 Ruby 2.0 Ruby 2.1 JRuby
2.0  
1.9

For additional driver versions, see Ruby Driver Language Compatibility Reference.

BSON

The Ruby BSON implementation is packaged in a separate gem with C and Java extensions for speed depending on the runtime enviroment.

Resources:

Object Mappers

Because MongoDB is so easy to use, the basic Ruby driver can be the best solution for many applications.

But if you need validations, associations, and other high-level data modeling functions then an Object Document Mapper may be needed.

In the context of a Rails application these provide functionality equivalent to, but distinct from, ActiveRecord. Because MongoDB is a document-based database, these mappers are called Object Document Mappers (ODM) as opposed to Object Relational Mappers (ORM).

Several mappers are available:

All the mappers build on top of the basic Ruby driver and so some knowledge of that is useful, especially if you work with a custom MongoDB configuration.

Notable Projects

Tools for working with MongoDB in Ruby are being developed daily. See Ruby External Resources.

If you are working on a project that you would like to have included, let us know.