【问题标题】:Rails 3, MongoId & bson version problemRails 3, MongoId & bson 版本问题
【发布时间】:2026-02-15 10:05:01
【问题描述】:

我刚刚更新到 Rails 3 final。现在我遇到了 MongoId、Mongo 的 Ruby 驱动程序和 bson 的问题。当我尝试运行 Rails 时,我得到“你已经激活了 bson 1.0.7,但是你的 Gemfile 需要 bson 1.0.4。考虑使用 bundle exec。(Gem::LoadError)”。

MongoId 需要 bson_ext 1.0.4,所以我的 Gemfile 中有 gem "bson_ext", "1.0.4"。我试图卸载 bson 1.0.7 但 Rails 无法启动,因为 Mongo Ruby 驱动程序需要 bson >= 1.0.5。

那么有什么想法可以解决这个问题吗?

【问题讨论】:

  • 经过 3 个小时的痛苦和痛苦,我解决了这个问题。我在我的 Gemfile 中需要“mongo”,因为在 Rails 3 rc2 中,这是 mongodb 工作所必需的,但现在它似乎破坏了它。所以我删除了这条线,现在一切都加载了。

标签: ruby-on-rails-3 mongoid bson


【解决方案1】:

这个组合对我有用:

gem 'rails',     '3.0.6'
gem "mongoid",   "2.0.0"
gem "bson",      "1.2.4"
gem "bson_ext",  "1.2.4"

gem "devise" ,   "1.1.6"

【讨论】: