“未初始化常量 MongoMapper::Base”执行 rake mongo:mongrate 时出错
我在“rake mongo:mongrate”尝试期间遇到以下错误:
$ rake mongo:mongrate --trace
(in /home/mei/Jobfully)
** Invoke mongo:mongrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute mongo:mongrate
== AddPricingPlans: migrating ================================================
-- add_column(:users, :plan_id, :string)
rake aborted!
uninitialized constant MongoMapper::Base
/home/mei/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in `rescue in load_missing_constant'
我的 Gemfile 中有以下内容 -
gem 'rake', '~>0.8'
gem 'mongo', '= 1.0.7' # must be same version as bson/bson_ext
gem 'bson', '= 1.0.4' # must be same version as bson_ext/mongo
gem 'bson_ext', '= 1.0.4' # must be same version as bson/mongo
gem 'mongo_mapper', '~> 0.8.2'
我还在 Rakefile 中添加了以下行 -
import 'vendor/plugins/mongrations/lib/tasks/mongo.rake'
关于如何解决此问题的任何想法?谢谢。
I got the following error during my "rake mongo:mongrate" attempt:
$ rake mongo:mongrate --trace
(in /home/mei/Jobfully)
** Invoke mongo:mongrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute mongo:mongrate
== AddPricingPlans: migrating ================================================
-- add_column(:users, :plan_id, :string)
rake aborted!
uninitialized constant MongoMapper::Base
/home/mei/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in `rescue in load_missing_constant'
I have the following in my Gemfile -
gem 'rake', '~>0.8'
gem 'mongo', '= 1.0.7' # must be same version as bson/bson_ext
gem 'bson', '= 1.0.4' # must be same version as bson_ext/mongo
gem 'bson_ext', '= 1.0.4' # must be same version as bson/mongo
gem 'mongo_mapper', '~> 0.8.2'
I also added the following line in Rakefile -
import 'vendor/plugins/mongrations/lib/tasks/mongo.rake'
Any ideas on how I can fix this problem? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MongoMapper::Base
在去年的某个时候被弃用(它甚至不再存在!)。您现在需要lib/mongo_mapper/mongrations.rb
中的MongoMapper.connection
,def connection
而不是MongoMapper::Base.connection< /代码>。
我不确定它什么时候坏掉的,但是做出这样的改变对我来说已经解决了问题。
如果你想对其进行猴子补丁,你可以使用:
MongoMapper::Base
was deprecated sometime in the last year (it no longer even exists!). You now wantMongoMapper.connection
inlib/mongo_mapper/mongrations.rb
,def connection
rather thanMongoMapper::Base.connection
.I'm not sure when it broke, but making that change has fixed mongrations for me.
If you want to monkeypatch it, you could use: