123456789_123456789_123456789_123456789_123456789_

Compatibility

Ruby MongoDB Driver Compatibility

The following compatibility table specifies the versions of Ruby driver for MongoDB (the mongo gem) supported by the most recent patch releases of the specified Mongoid versions.

Note

Older versions of Mongoid within the same minor release may support older driver versions. For example, Mongoid 7.0.5 supports driver versions 2.5 and newer, whereas Mongoid 7.0.6 requires driver version 2.7 or newer.

Mongoid Driver 2.19-2.18 Driver 2.17-2.10 Driver 2.9-2.7
8.0 thru 9.0   ✓
7.2 thru 7.5   ✓   ✓
7.0 thru 7.1   ✓   ✓   ✓

Ruby Compatibility

The following compatibility table specifies the versions of Ruby interpreters supported by Mongoid. "D" in a column means support for that Ruby version is deprecated.

Mongoid Ruby 3.2 Ruby 3.1 Ruby 3.0 Ruby 2.7 Ruby 2.6 Ruby 2.5 Ruby 2.4 Ruby 2.3 Ruby 2.2 JRuby 9.4 JRuby 9.3 JRuby 9.2
9.0   ✓   ✓   ✓   ✓   ✓
8.1   ✓   ✓   ✓   ✓   ✓   ✓
8.0   ✓   ✓   ✓   ✓   ✓
7.5   ✓   ✓   ✓   ✓ D   ✓ D
7.4   ✓   ✓   ✓   ✓   ✓   ✓
7.3   ✓[^1]   ✓[^2]   ✓   ✓   ✓ D D   ✓
7.2   ✓[^3]   ✓[^4]   ✓   ✓   ✓ D D   ✓
7.1   ✓[^5]   ✓[^6]   ✓   ✓   ✓   ✓[^7]   ✓   ✓
7.0   ✓   ✓   ✓   ✓[^8]   ✓   ✓[^9]   ✓

MongoDB Server Compatibility

The following compatibility table specifies the recommended version(s) of Mongoid for use with a specific version of MongoDB server.

Note that in order to use features of a particular MongoDB server version, both the driver and Mongoid must support that server version. Please refer to the driver compatibility page for driver compatibility matrices.

"D" in a column means support for that MongoDB server version is deprecated and will be removed in a next version.

Mongoid MongoDB 7.0 MongoDB 6.0 MongoDB 5.0 MongoDB 4.4 MongoDB 4.2 MongoDB 4.0 MongoDB 3.6 MongoDB 3.4 MongoDB 3.2 MongoDB 3.0 MongoDB 2.6
8.0 thru 9.0   ✓   ✓   ✓   ✓   ✓   ✓   ✓
7.4 thru 7.5   ✓   ✓   ✓   ✓   ✓   ✓   ✓ D D D D
7.0 thru 7.3   ✓   ✓   ✓   ✓   ✓ D D D D

Rails Compatibility

The following compatibility table specifies which versions of Ruby on Rails are supported by Mongoid.

Mongoid Rails 7.1 Rails 7.0 Rails 6.1 Rails 6.0 Rails 5.2 Rails 5.1
9.0   ✓[^10]   ✓   ✓   ✓
8.0 thru 8.1   ✓[^11]   ✓   ✓   ✓   ✓[^12]
7.5   ✓   ✓   ✓   ✓[^13] D
7.4   ✓   ✓   ✓   ✓[^14]   ✓[^15]
7.3   ✓[^16]   ✓   ✓   ✓[^17]   ✓[^18]
7.2   ✓[^19]   ✓   ✓[^20]   ✓[^21]
7.1   ✓[^22]   ✓   ✓   ✓
7.0   ✓[^23]   ✓[^24]   ✓   ✓

Rails Frameworks Support

Ruby on Rails is comprised of a number of frameworks, which Mongoid attempts to provide compatibility with wherever possible.

Though Mongoid attempts to offer API compatibility with Active Record, libraries that depend directly on Active Record may not work as expected when Mongoid is used as a drop-in replacement.

Note

Mongoid can be used alongside Active Record within the same application without issue.

Rails Framework Supported?
ActionCable   ✓[^25]
ActionMailbox [^26]
ActionMailer   ✓
ActionPack   ✓
ActionText [^27]
ActionView   ✓
ActiveJob   ✓[^28]
ActiveModel   ✓[^29]
ActiveStorage [^30]
ActiveSupport   ✓[^31]

[^1]: Mongoid version 7.3.2 or higher is required.

[^2]: Mongoid version 7.3.2 or higher is required.

[^3]: Mongoid version 7.2.5 or higher is required.

[^4]: Mongoid version 7.2.5 or higher is required.

[^5]: Mongoid version 7.1.10 or higher is required.

[^6]: Mongoid version 7.1.10 or higher is required.

[^7]: Ruby version 2.4.1 or higher is required.

[^8]: Ruby version 2.4.1 or higher is required.

[^9]: Ruby version 2.2.2 or higher is required.

[^10]: Rails 7.1 requires Mongoid 8.0.7 or 8.1.3 in the respective 8.0 and 8.1 stable branches.

[^11]: Rails 7.1 requires Mongoid 8.0.7 or 8.1.3 in the respective 8.0 and 8.1 stable branches.

[^12]: Using Rails 5.x with Ruby 3 is not supported.

[^13]: Using Rails 5.x with Ruby 3 is not supported.

[^14]: Using Rails 5.x with Ruby 3 is not supported.

[^15]: Using Rails 5.x with Ruby 3 is not supported.

[^16]: Rails 7.x requires Mongoid 7.3.4 or later.

[^17]: Using Rails 5.x with Ruby 3 is not supported.

[^18]: Using Rails 5.x with Ruby 3 is not supported.

[^19]: Rails 6.1 requires Mongoid 7.0.12, 7.1.7 or 7.2.1 in the respective 7.0, 7.1 and 7.2 stable branches.

[^20]: Using Rails 5.x with Ruby 3 is not supported.

[^21]: Using Rails 5.x with Ruby 3 is not supported.

[^22]: Rails 6.1 requires Mongoid 7.0.12, 7.1.7 or 7.2.1 in the respective 7.0, 7.1 and 7.2 stable branches.

[^23]: Rails 6.1 requires Mongoid 7.0.12, 7.1.7 or 7.2.1 in the respective 7.0, 7.1 and 7.2 stable branches.

[^24]: Rails 6.0 requires Mongoid 7.0.5 or later.

[^25]: There is currently no MongoDB adapter for ActionCable, however any existing adapter (such as Redis) can be used successfully in conjunction with Mongoid models

[^26]: Depends directly on ActiveRecord

[^27]: Depends directly on ActiveRecord

[^28]: Serialization of BSON & Mongoid objects works best if you explicitly send ::BSON::ObjectId's as strings, and reconstitute them in the job:

``` ruby
record = Model.find(...)
MyJob.perform_later(record._id.to_s)

class MyJob < ApplicationJob
  def perform(id_as_string)
    record = Model.find(id_as_string)
    # ...
  end
end
```

[^29]: ::Mongoid::Document includes ActiveModel::Model and leverages ActiveModel::Validations for validations

[^30]: Depends directly on ActiveRecord

[^31]: Mongoid requires ActiveSupport and uses it extensively, including ::ActiveSupport::TimeWithZone for time handling.