This simple template includes everything you need to run Rails with MongoDB. It includes examples for basic document fetches, as well as a form to add new entries.
Find out more in the article in the MongoDB Dev Center.
You will need a MongoDB cluster ready to go with some sample data. The easiest way to get started is with an Atlas free cluster.
Create a new Rails application using this template. You can change the name of the project by replacing rails-mongodb with the name of your project.
rails new rails-mongodb -m https://raw.githubusercontent.com/mongodb-developer/rails-mongodb/main/template.rb --skip-active-record
When prompted, enter the connection string to your MongoDB cluster. You can find this connection string in the Atlas UI.
Start the Rails server:
cd rails-mongodb
rails s
Open your browser on http://localhost:3000, and start exploring your new application.