Reputation: 2319
I'm trying to upgrade Mongoid in an Rails 4.2 app from 4.x to 5.x (5.4.1) to connect to a MongoDB 2.6.
I've updated the mongoid.yml
file to match the differences of 5.x:
development:
clients:
default:
database: my_db
hosts:
- localhost:27017
options:
but now when i try to run a query, for example User.count
i get the following error:
Mongo::Error::UnsupportedFeatures (Server at (localhost:27017) reports wire version (2), but this version of the Ruby driver requires at least (6).)
The docs say that Mongoid 5.x is compatible with MongoDB 2.6, so why the error?
I have another rails app (6.x) that uses Mongoid 7.x and connects fine to the same database.
Note: Ruby 2.6
OS: MacOS
Upvotes: 1
Views: 3683
Reputation: 39
I had the same error with embedded mongo/java/spring. Solved it by spring.mongodb.embedded.version=2.6.0
with
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>2.2.0</version>
</dependency>
Upvotes: 0
Reputation: 2319
So @javiyu's answer pointed me in the right direction, MongoDB's documentation is indeed confusing, while Mongoid itself supports MongoDB 2.6, the ruby MongoDB driver dropped support of MongoDB 2.6 from version 2.16 (deprecated and fully dropped from 2.17, which was the version i was running on), so pinning the version to 2.15 did the trick:
#last version that supports mongodb 2.6
gem 'mongo', "~> 2.15.0"
#last version to support rails 4.2, above that requires at least rails 5
gem 'mongoid', "~> 5.4.0"
Upvotes: 0
Reputation: 1474
MongoDB documentation is a bit confusing here.
The link you posted is referring the the compatibility between mongoid and the ruby mongodb driver.
There is another page with a matrix representing the compatibility of the ruby driver and the mongoDB server.
Upvotes: 1