Tag: bson

为什么安装bson_ext会出错?

当我在Rails项目文件夹中执行以下命令时: gem install bson_ext 我收到这个错误: #result Building native extensions. This could take a while… ERROR: Error installing bson_ext: ERROR: Failed to build gem native extension. /home/absolute/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb checking for asprintf()… yes checking for ruby/st.h… yes checking for ruby/regex.h… yes checking for ruby/encoding.h… yes creating Makefile make compiling bson_buffer.c compiling cbson.c cbson.c: In function ‘write_element’: cbson.c:439:17: […]

BSON :: ObjectId vs Mongo :: ObjectID

在在线API中,它们指的是Mongo::ObjectID 。 我require ‘mongo’但仍然没有找到它。 例如,我需要通过Id找到一个对象,我正在做: mongo_db[‘post’].find({_id: Mongo::ObjectID(params[:id])}).next 它似乎无法找到Mongo :: ObjectID并导致: NoMethodError – undefined method “ObjectID’ for Mongo:Module: 所以过了一段时间我开始require ‘bson’并且正在做 mongo_db[‘post’].find({_id: BSON::ObjectId(params[:id])}).next 它工作了! 那么BSON :: ObjectId和Mongo :: ObjectID之间的区别是什么?我需要做些什么来使后者工作(我真的需要)吗? PS:我有 bson (1.5.2, 1.4.1) Authors: Jim Menard, Mike Dirolf, Kyle Banker Homepage: http://www.mongodb.org Installed at (1.5.2): /usr/local/lib64/ruby/gems/1.9.1 (1.4.1): /usr/local/lib64/ruby/gems/1.9.1 Ruby implementation of BSON mongo (1.5.2, 1.4.1) Authors: Jim […]