Ruby on Rails 和 MongoDB

发布于 2024-12-19 02:30:28 字数 683 浏览 1 评论 0 原文

我有一个新的 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 不是同一版本。

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

I have a new Ruby on Rails installation where I can see the default start-page.

I followed this guide in order to install MongoDB to Rails.

Now I get this error when running 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.

I have installed the bson_ext gem, which means that now bson_ext in not in my load path or that the gems are not the same version.

Where is the load path? How can I change it?
How do I check if the gems are the same version?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情释 2024-12-26 02:30:28

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

If you're using Ruby on Rails 3+, you should check that the bson_ext gem is referenced in your Gemfile.

怪我太投入 2024-12-26 02:30:28

打开 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 测试任务将正常运行。有关更多详细信息,请参阅约翰的帖子。

他们还引用了 John Wood 的帖子 这非常好。

Open up Gemfile (in your rails app's root directory) and add a line that says: bson_ext

You should have:

gem mongo
gem bson_ext

Also here is some more info from 10gen docs on running tests in rails:

Running Tests
A slight modification is required to get rake test working (thanks to John P. Wood). Create a file lib/tasks/mongo.rake containing the following:

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

Now the various rake test tasks will run properly. See John's post for more details.

They also reference John Wood's post which is quite good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文