问题描述
我无法让 MongoMapper 与我的 Rails 应用程序一起工作.我收到此错误消息:
I can't get MongoMapper to work with my Rails app. I get this error message:
**注意:未加载 C 扩展.这是优化 MongoDB Ruby 驱动程序性能所必需的.您可以按如下方式安装扩展:gem 安装 bson_ext
**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance. You can install the extension as follows: gem install bson_ext
如果您在安装后继续收到此消息,请确保bson_ext gem 位于您的加载路径中,并且 bson_ext 和 mongo gem 的版本相同.
If you continue to receive this message after installing, make sure that the bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version.
我已经安装了 DevKit 并安装了 gem: gem install bson_ext --no-rdoc --no-ri(结果:安装了 bson_ext-1.0.1)
I have installed DevKit and installed the gem: gem install bson_ext --no-rdoc --no-ri (result: bson_ext-1.0.1 installed)
我在 Windows 7 上运行.Rails 版本是 2.3.7.我在安装时使用了 RubyInstaller.有人能指出我正确的方向吗?
I'm running on Windows 7. The Rails version is 2.3.7. I used the RubyInstaller when installing. Can anyone point me in the right direction?
推荐答案
问题是:bson_ext gem 版本和 mongo gem 版本需要匹配,而且 mongo_mapper 还没有为 mongo-1.0.1 做好准备,所以您应该使用的 mongo 和 bson_ext gem 的版本分别为 1.0.
The problem is: the bson_ext gem version and the mongo gem version need to match, also, mongo_mapper isn't ready for mongo-1.0.1 yet, so the versions of the mongo and bson_ext gems you should be using are 1.0 for each, respectively.
因此,请执行以下操作:
so, do the following:
gem install mongo -v=1.0 --no-ri --no-rdoc && \
gem install bson_ext -v=1.0 --no-ri --no-rdoc
然后在你的 config/environment.rb 中为 Rails 2.x 做:
then for Rails 2.x in your config/environment.rb do:
config.gem 'mongo', :version => '1.0'
config.gem 'bson_ext', :version => '1.0'
或者对于 Rails 3,在您的 Gemfile 中:
or for Rails 3, in your Gemfile:
gem 'mongo', '1.0'
gem 'bson_ext', '1.0'
这篇关于MongoMapper 和 bson_ext 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!