Fetching contributors…
Cannot retrieve contributors at this time
194 lines (136 sloc) 4.66 KB
.. http://www.mongodb.org/display/DOCS/Ruby+Language+Center
.. _ruby-language-center:
===================
Ruby MongoDB Driver
===================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: twocols
.. admonition:: Ruby Driver 2.0 Released
For more information, see
`Announcing Ruby Driver 2.0, a Rewrite <http://www.mongodb.com/blog/post/announcing-ruby-driver-20-rewrite?jmp=docs>`_.
This is an overview of the available tools and suggested practices for
using Ruby with MongoDB. To skip to more detailed
discussion see:
- :ref:`ruby-driver-tutorial`
- :ref:`ruby-driver-tutorial-2-0`
- :ref:`ruby-bson-tutorial`
- :ref:`ruby-bson-tutorial-4-0`
- :ref:`ruby-mongoid-tutorial`
For a list of external resources, see :ref:`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:
- `Ruby Driver Source Code <https://github.com/mongodb/mongo-ruby-driver>`_
Compatibility
-------------
MongoDB Compatibility
`````````````````````
.. include:: /includes/extracts/ruby-driver-compatibility-matrix-mongodb.rst
.. list-table::
:header-rows: 1
:stub-columns: 1
:widths: 20 20 20 20 20
:class: compatibility
* - Ruby Driver
- MongoDB 2.4
- MongoDB 2.6
- MongoDB 3.0
- MongoDB 3.2
* - 2.2
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 2.0
- |checkmark|
- |checkmark|
- |checkmark|
-
* - 1.12
- |checkmark|
- |checkmark|
- |checkmark|
-
.. include:: /includes/extracts/ruby-driver-compatibility-full-mongodb.rst
.. include:: /includes/older-server-versions-unsupported.rst
Language Compatibility
``````````````````````
.. include:: /includes/extracts/ruby-driver-compatibility-matrix-language.rst
.. list-table::
:header-rows: 1
:stub-columns: 1
:class: compatibility
* - Ruby Driver
- Ruby 1.8.7
- Ruby 1.9
- Ruby 2.0
- Ruby 2.1
- JRuby
* - 2.0
-
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
* - 1.9
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
.. include:: /includes/extracts/ruby-driver-compatibility-full-language.rst
.. include:: /includes/unicode-checkmark.rst
BSON
----
The Ruby BSON implementation is packaged in a separate gem with C and
Java extensions for speed depending on the runtime enviroment.
Resources:
- `BSON Source Code <https://github.com/mongodb/bson-ruby>`_
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).
The ODM officially supported by MongoDB is Mongoid_, originally written by Durran Jordan.
Several other mappers are available:
- `MongoMapper <http://mongomapper.com/>`_ from John Nunemaker
- `Mongomatic <http://mongomatic.com/>`_ from Ben Myles
- `MongoODM <https://github.com/carlosparamio/mongo_odm>`_ from Carlos Paramio
- `MongoModel <http://www.mongomodel.org/>`_ from Sam Pohlenz
- `DriverAPILayer <http://alexeypetrushin.github.com/mongodb/driver.html>`_ from Alexey Petrushin
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.
.. _Mongoid: http://mongoid.org/en/mongoid/index.html
Notable Projects
----------------
Tools for working with MongoDB in Ruby are being developed daily.
See :ref:`ruby-external-resources`.
If you are working on a project that you would like to have included,
let us know.
.. REMOVED PRESENTATIONS:
[Introduction to MongoDB and Ruby|http://www.mongodb.com/presentations/webinar/introduction-mongodb-and-ruby] (September 2012)
[MongoDB & Ruby Presentations|https://www.mongodb.com/presentations?application=&programming_lang=ruby&event=]
Documentation
-------------
.. toctree::
:titlesonly:
/drivers/ruby-resources
/tutorial/ruby-driver-tutorial
/tutorial/ruby-driver-tutorial-2-0
/tutorial/ruby-bson-tutorial
/tutorial/ruby-bson-tutorial-4-0
/tutorial/ruby-mongoid-tutorial