Saturday, June 6

Analyze Data with MongoDB and Ruby

This post gives a quick and very brief introduction on how to use MongoDB with Ruby. We will see how to install and connect to a MongoDB, how to populate the database with fake documents generated in just a couple of lines of code, and how to build some queries to gain insights into the stored documents. Prerequisites Let’s assume you already have Ruby installed. Throughout this post, we are going to create a small playground consisting of a few files. Let’s create a project directory for them: mkdir -p ~/projects/rumo and cd ~/projects/rumo (rumo for Ruby Mongo). I also like to use rvm to create a fresh and separate Ruby environment for each project: rvm --rvmrc --create 2.3.1 and cd ./ to load the configuration. But that’s ...