1

我有一个新的 Ruby on Rails 安装,我可以在其中看到默认的起始页。

我按照本指南将 MongoDB 安装到 Rails。

现在我在运行时收到此错误rake test

**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

  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.

我已经安装了 bson_ext gem,这意味着现在 bson_ext 不在我的加载路径中,或者 gem 的版本不同。

加载路径在哪里?我怎样才能改变它?如何检查宝石是否为同一版本?

4

2 回答 2

5

如果您使用的是 Ruby on Rails 3+,您应该检查您的 Gemfile 中是否引用了 bson_ext gem。

于 2011-11-29T23:40:36.757 回答
2

打开 Gemfile(在您的 rails 应用程序的根目录中)并添加一行内容:bson_ext

你应该有:

gem mongo
gem bson_ext

这里还有一些来自10gen 文档的关于在 rails 中运行测试的更多信息:

运行测试 需要稍作修改才能使 rake 测试正常工作(感谢 John P. Wood)。创建一个包含以下内容的文件 lib/tasks/mongo.rake:

namespace :db do
  namespace :test do
    task :prepare do
      # Stub out for MongoDB
    end
  end
end

现在各种 rake 测试任务将正常运行。有关详细信息,请参阅约翰的帖子。

他们还参考了约翰伍德的帖子,这非常好。

于 2011-11-29T23:49:33.503 回答