Docs Menu

Download and Install

To create the Quick Start application by using Sinatra, you need the following software installed in your development environment:

In Ruby, packages are called gems.

Complete the following steps to install and add the Mongoid and Sinatra gems to your web application.

1

Ensure that the version of Mongoid you install is compatible with the version of Ruby installed on your operating system. To learn which versions are compatible, see the Compatibility page.

Run the following command to install the Mongoid gem:

gem install mongoid

When the installation completes, the command outputs the following message:

Successfully installed mongoid-9.0.4
Parsing documentation for mongoid-9.0.4
Installing ri documentation for mongoid-9.0.4
Done installing documentation for mongoid after 1 seconds
1 gem installed
2

Run the following commands to generate a new directory called my-sinatra-app and enter it:

mkdir my-sinatra-app
cd my-sinatra-app
3

All Ruby applications must have a Gemfile that lists the required gems. Run the following command to create a Gemfile in your application:

touch Gemfile

Paste the following content into the Gemfile to add the required gems:

source 'https://rubygems.org'
gem 'sinatra'
gem 'mongoid'
gem 'rackup'

The rackup gem provides a web server interface for your application.

4

Run the following command to install the specified gems into your application:

gem install bundler
bundle install

When the command runs successfully, the output in your shell contains a Bundle complete! message and describes the number of new gems installed.

After completing these steps, you have a new Sinatra web application with Mongoid installed.

Note

If you run into issues, ask for help in the MongoDB Community Forums or submit feedback by using the Feedback button in the upper right corner of the page.