Uninitialized constant BSON
shj333 opened this issue · 8 comments
The moped adapter (moped.rb) uses ::BSON::ObjectId, but Mongoid/Moped has changed this to Moped::BSON::ObjectId (see http://mongoid.org/en/mongoid/docs/upgrading.html and mongoid/mongoid@fab5cc8). Applications using the Mongoid Gem hit the exception:
uninitialized constant BSON
Hello, @shj333 . Try to use 0.6.2 version, because 0.6.3 working with moped 3 version. It this will help, then I will add notice in Readme.
Thank you for responding so quickly. Maybe I'm missing something, but your version 0.6.2 (::Moped::BSON::ObjectId.new) seems to support Mongoid 3 but version 0.6.3 (::BSON::ObjectId.new) does not. Not sure why the change to the older version of the Mongoid/Moped API.
Thank you for providing such a useful Gem. Really appreciate your efforts.
Sorry, @shj333 . I mean new moped 2.0.0. https://rubygems.org/gems/moped/versions/2.0.0.beta6 - Devs change API for this driver. https://github.com/mongoid/moped/blob/a2cda45884714808eec1d39d4fbb743d4b206a0e/CHANGELOG.md#200 - third point. But I can try to fix this. Like check:
(defined?(::Moped::BSON::ObjectId) ? ::Moped::BSON::ObjectId : :BSON::ObjectId).new
What do you think?
@shj333 can you try master branch?
gem 'mongodb_logger', github: 'le0pard/mongodb_logger'
Ah, now I see. I hadn't looked at new Moped 2.0 release. Well, that definitely puts dependent Gems in a difficult place. You could do what you suggest above or use Ruby OO and create separate adaptors for the two different releases. I prefer the latter since the adaptor needs to peg a different API depending on whether it's using Moped 1 or Moped 2. I can help with this if you want some help. Otherwise, we'll go with your solution. Thanks.
I'll try that now.
Released in v0.6.4.