【问题标题】:uninitialized constant Mongoid::Taggable::Mongo未初始化的常量 Mongoid::Taggable::Mongo
【发布时间】:2012-12-20 06:24:57
【问题描述】:

我在我的 Gemfile 中添加了mongoid-taggable,然后在我的模型中添加了include Mongoid::Taggable,但收到了一条错误消息:

uninitialized constant Mongoid::Taggable::Mongo

错误跟踪:

app/models/recipe.rb:13:in `include'
app/models/recipe.rb:13:in `<class:Recipe>'
app/models/recipe.rb:2:in `<top (required)>'
app/controllers/recipes_controller.rb:11:in `index'

有没有人能解决这个问题?

【问题讨论】:

  • 您是否重新启动了服务器? :)
  • @MikhailNikalyukin 是的,服务器重新启动。我刚刚从头开始创建了标签,但仍然想找出问题所在。
  • 你用的是什么版本的 Mongoid?

标签: ruby-on-rails mongoid


【解决方案1】:

如果不深入挖掘 Mongoid Taggable 的源代码,我猜它是为 Mongoid 的 2.x.x 版本构建的。在 Mongoid 的 3.x.x 版本中,移除了对 mongo gem 的依赖。一年多来似乎没有人致力于这个 gem,所以我怀疑它是否支持 Mongoid 的 3.x.x 版本。

如果您打算使用此 gem 进行标记,则需要回滚到早期版本的 Mongoid。 2.4.12 是 2.x.x 分支中的最后一个稳定版本。

另一种解决方案是使用不同的 gem。我会推荐mongoid-tags-arent-hard。它与 Mongoid 3 兼容,并且运行良好。

【讨论】:

  • 我使用this brunch作为插件来解决它。并感谢您的推荐,效果很好! :)
  • 很抱歉,我没有足够的声誉来投票支持您的答案。稍后会回来投票。 :)
猜你喜欢
  • 2013-02-16
  • 2021-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-08
  • 1970-01-01
相关资源
最近更新 更多