Download and Install
Prerequisites
To create the Quick Start application by using Sinatra, you need the following software installed in your development environment:
A terminal app and shell. For MacOS users, use Terminal or a similar app. For Windows users, use PowerShell.
Download and Install the Mongoid and Framework Gems
In Ruby, packages are called gems.
Complete the following steps to install and add the Mongoid and Sinatra gems to your web application.
Install Mongoid
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
Create a Gemfile
and add gems
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.
Install gems
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.