Home > mongomapper-rails3-sample

mongomapper-rails3-sample

Mongomapper-rails3-sample is a project mainly written in RUBY and JAVASCRIPT, it's free.

A sample application to demonstrate how to use MongoDB with Rails 3 via MongoMapper

= Description

This is a very simple Rails 3 sample application that demonstrates how to use MongoMapper and play with the MongoDB database engine.

There are 2 models: Book and Author. I just wanted to demonstrate how to do associations ala ActiveRecord.

I have followed this {exellent tutorial}[http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started] to get me started.

== Requirements

=== MongoDB:

Install the MongoDB (server and client) for your platform http://www.mongodb.org/downloads

=== Gems (mongo, MongoMapper and bson_ext)

The Gemfile has a "require 'mongo'" clause just before the gem command to ensure that a dependency (bson_ext) is correctly loaded. FOr this reason you have to install mongo before running bundle install.

sudo gem install mongo

and then

bundle install

== Other

Since we're not using ActiveRecord, we have to specify the --orm option when generating a model. For example: rails generate model Book --orm mongo_mapper

At the moment, the model generator does not exist in the gem itself so I use the rails3-generators gem (https://github.com/indirect/rails3-generators) instead.

Previous:webapp