Skip to content

uninitialized constant Moped::BSON::Binary #46

Description

@jeremy6d

Running into this on Rails 4.1.4, Mongoid 4.0.0, Carrierwave 0.10.0, carrierwave-mongoid 0.7.1 and Mongoid-grid_fs 2.1.0 4dbecf1.

When uploading files via Carrierwave into GridFS, it's blowing up in lib/mongoid/grid_fs.rb in the "binary_for" method on line 172:

          def binary_for(*buf)
            if defined?(Moped::BSON)
              Moped::BSON::Binary.new(:generic, buf.join)
            else
              BSON::Binary.new(buf.join, :generic)
            end
          end

The problem seems to be that Moped::BSON is still defined somewhere in the project, so it's using the old Moped BSON class even though that's been phased out. Actually, I found that if I change it to

if defined?(Moped::BSON::Binary)

it works just fine, but I'm not exactly sure what the consequences of that are (I honestly don't know what the Moped::BSON constant is defined at all).

I'll fork and submit a pull request, and let you guys decide. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions