Over a million developers have joined DZone.

Building Your First MongoDB App in Ruby: An OSCON 2012 Tutorial

· Database Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database. Try it now! Brought to you in partnership with MongoDB.

This is a 3 hour tutorial I wrote for and gave at OSCON 2012.

Here is the summary:

This tutorial will introduce the features of MongoDB by building a simple location-based application using MongoDB. The tutorial will cover the basics of MongoDB’s document model, query language, map-reduce framework and deployment architecture.

The tutorial will be divided into 5 sections:

  • Data modeling with MongoDB: documents, collections and databases
  • Querying your data: simple queries, geospatial queries, and text-searching
  • Writes and updates: using MongoDB’s atomic update modifiers
  • Trending and analytics: Using mapreduce and MongoDB’s aggregation framework
  • Deploying the sample application

Besides the knowledge to start building their own applications with MongoDB, attendees will finish the session with a working application they use to check into locations around Portland from any HTML5 enabled phone!

TUTORIAL PREREQUISITES
Each attendee should have a running version of MongoDB. Preferably the latest unstable release 2.1.x, but any install after 2.0 should be fine. You can dowload MongoDB at http://www.mongodb.org/downloads.

Instructions for installing MongoDB are at http://docs.mongodb.org/manual/installation/.

Additionally we will be building an app in Ruby. Ruby 1.9.3+ is required for this. The current latest version of ruby is 1.9.3-p194.

We will be using the following GEMs and they MUST BE installed ahead of time so you can be ahead of the game and safe in the event that the Internet isn’t accommodating.

  • bson (1.6.4)
  • bson_ext (1.6.4)
  • haml (3.1.4)
  • mongo (1.6.4)
  • rack (1.4.1)
  • rack-protection (1.2.0)
  • rack shotgun (0.9)
  • sinatra (1.3.2)
  • tilt (1.3.3)

Prior ruby experience isn’t required for this. We will NOT be using rails for this app.

 

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.

Topics:

Published at DZone with permission of Steve Francia, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}