"uninitialized constant MongoMapper::Base" error when doing rake mongo:mongrate
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/r开发者_如何学Cuby-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.
MongoMapper::Base
was deprecated sometime in the last year (it no longer even exists!). You now want MongoMapper.connection
in lib/mongo_mapper/mongrations.rb
, def connection
rather than MongoMapper::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:
module MongoMapper
class Base
def self.connection
MongoMapper.connection
end
end
end
精彩评论