Reputation: 3727
I have a library I was working on have left it for a while, when I went back to work on it, it's still fine but when I updated gems: mongoid from 2.4.5
to 3.0.6
and also updated mongo and bson_ext from 1.6.0
to 1.7.0
and when run my rspec I get error
<top (required)>': uninitialized constant Mongo (NameError)
from
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("db_test")
end
I have: ruby 1.9.3p125 mongodb 2.0.2-x86_64
This one has the same problem Mongoid gives uninitialized constant Mongo but the solution didn't work for me.
Adding require "mongo"
on mine gives a different error:
spec_helper.rb:11:in 'block in <top (required)>': undefined method 'master=' for Mongoid::Config:Module (NoMethodError)
EDIT I still used 3.x and this is now how they do connections
Mongoid.configure do |config|
config.connect_to("db_test")
end
Upvotes: 1
Views: 5015
Reputation: 30136
Mongoid 3.x does not use the mongo gem anymore, it uses a driver called moped developed by the Mongoid team.
If you want to stick with the official 10gen driver you would need to update your Gemfile to specify you want to stick with Mongoid 2.x:
gem "mongoid", "~> 2.0"
Upvotes: 1