Getting Started with MongoDB and Ruby
MongoDB a is a high-performance, open source, schema-free, document-oriented database written in C++. It's sort of a cross between scalable key/value stores and traditional functionality-rich relational databases.
MongoDB might be useful as a fast, simple, non-transactional data store for a web application, or as a caching mechanism. You don't ever need to worry about migrations due to Mongo's schema-less nature.
Getting started with MongoDB using Ruby is now fairly straightforward thanks to the Mongo Ruby driver. This provides access to the core Mongo database operations, and natively supports many Ruby objects without requiring conversion (including nested hashes). There's even an ActiveRecord connection adapter for Mongo.
Earlier this week, John Nunemaker announced his MongoMapper, a wrapper for MongoDB which includes typecasting, callbacks, validations and other ActiveRecord-like features. The project is heading towards drop-in Rails compatibility.
MongoMapper uses a default connection from the Ruby driver, and to create a MongoMapper model you just need to include MongoMapper::Document
in the class (as opposed to ActiveRecord's inheritance pattern). From there, it's simple to define your document's keys, validations and callbacks.
The MongoMapper gem is available from RubyForge or Github, and you can read more on RailsTips.