Download and Install
Prerequisites
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.
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 Rails gems to your web application.
Create a Rails app with default scaffolding
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.
Install gems
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.