Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant Moped::BSON::Binary #46

Open
jeremy6d opened this issue Jul 7, 2014 · 3 comments
Open

uninitialized constant Moped::BSON::Binary #46

jeremy6d opened this issue Jul 7, 2014 · 3 comments

Comments

@jeremy6d
Copy link

jeremy6d commented Jul 7, 2014

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.

@mu-is-too-short
Copy link

Did you ever get any resolution on this? I just hit the same problem while trying to upgrade a Rails3 app to Rails4. My current plan is to fork my own copy and beat some sense into it.

@rmm5t
Copy link
Collaborator

rmm5t commented Jan 9, 2015

I honestly don't know what the Moped::BSON constant is defined at all

Mongoid, Moped, and BSON have had a strange history with one another. At one time, Moped did not depend on the bson gem for it's BSON handling. That's why there's the Moped::BSONcheck.

Moped::BSON should have completely gone away, so please see if you can find out where Moped::BSON is still being defined.

@mu-is-too-short
Copy link

@rmm5t Thanks. I think I've found some stray Moped::BSON things in my code that are confusing mongoid-grid_fs's defined? calls. I love upgrading, it is the best time ever! Heh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants