Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4047

conflict between mongoid and mongo (mongo-ruby-driver)

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      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'

      1. 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)

      1. @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

      2. @data_in_chunk = []
        end

            Assignee:
            Unassigned Unassigned
            Reporter:
            poc7667 poc7667
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: