March 2019
Intermediate to advanced
394 pages
11h 4m
English
Using a low-level driver to connect to the MongoDB database is often not the most efficient route. All the flexibility that a low-level driver provides is offset against longer development times and code to glue our models with the database.
An ODM can be the answer to these problems. Just like ORMs, ODMs bridge the gap between our models and the database. In Rails, the most widely-used MVC framework for Ruby—Mongoid—can be used to model our data in a similar way to Active Record.
Installing gem is similar to the Mongo Ruby driver, by adding a single file in the Gemfile, as shown in the following code:
gem 'mongoid', '~> 7.0'
Depending on the version of Rails, we may need to add the following to application.rb as well:
config.generators ...
Read now
Unlock full access