Docs Menu
Docs Home
/ / /
Mongoid
/

Download and Install

To create the Quick Start application by using Ruby on Rails 8, you need the following software installed in your development environment:

  • Ruby language. Rails requires Ruby v3.1.0 or later. Use the latest version to prevent version conflicts.

  • RubyGems package manager.

  • A terminal app and shell. For MacOS users, use Terminal or a similar app. For Windows users, use PowerShell.

In Ruby, packages are called gems.

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

1

Install the rails gem, which provides a command-line interface to create a basic application structure and application components.

Run the following command to install rails:

gem install rails
2

Run the following commands to create a new Rails application directory with default scaffolding and enter the application:

rails new my-rails-app --skip-active-record
cd my-rails-app

The --skip-active-record flag instructs Rails to not add Active Record as a dependency. You don't need this dependency because you will use Mongoid instead.

Tip

MacOS Installation Issue

If you are using macOS, you might encounter issues when creating a new Rails app during the automatic bundle installation step. First, make sure that your macOS and Xcode versions are up to date. If you receive an error message similar to the following, you must update or configure your build tools:

The compiler failed to generate an executable file.
...
(RuntimeError) You have to install development tools first.

Run the following commands to install Xcode command line tools:

xcode-select --install
xcodebuild -license accept

Then, try to run the bundle install command again.

3

Open the Gemfile in your application and add the following entry:

gem 'mongoid'
4

Run the following command to install the 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 Rails 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.

Back

Quick Start - Ruby on Rails