I need to use the two gems mongoid
and mongo
in my Rails app.
Any ideas to workaround this troublesome problem thanks~
gem 'mongo', '2.0.2',:git => 'git://github.com/mongodb/mongo-ruby-driver.git'
gem 'mongoid', '4.0.0'
# gem "mongo_mapper"
Error message
Bundler could not find compatible versions for gem "bson":
In Gemfile:
mongo (= 2.0.2) ruby depends on
bson (~> 3.0) ruby
mongoid (= 4.0.0) ruby depends on
moped (~> 2.0.0) ruby depends on
bson (~> 2.2) ruby
UPDATE
Mongoid is handy , but sometime it is sucks,
because I got error 'Client Error: Remaining data too small for BSON object
,
and even I wrapped it in begin rescue block
, it still break my Rails app, and stop the import data task, what the suck Mongoid is ! So I decided to give up use Mongoid to insert new records to collection , I tried to use mongo
. But they are conflict in my Rails app, WTH again !
def bulk_insert_to_collection(collection_name)
model = collection_name.capitalize.constantize.new
begin
model.collection.insert(@data_in_chunk)
# @bulk.execute
rescue Exception=>err
log_error "[#{err}] File #{@file_path}: line of #{i} #{Time.now}"
rescue Exception => err
log_error "[#{err}] File #{@file_path}: line of #{i} #{Time.now}"
rescue => err
p ex
log_error "[#{err}] File #{@file_path}: line of #{i} #{Time.now}"
end
# @data_in_chunk = []
end