开发者

"NameError: uninitialized constant User::MongoMapper" trying to MongoMapper 'Getting Started'

Here's my irb session:

irb(main):001:0> class User
irb(main):002:1> include MongoMapper::Document
irb(main):003开发者_开发技巧:1> key :name, String
irb(main):004:1> key :age, Integer
irb(main):005:1> many :hobbies
irb(main):006:1> end
NameError: uninitialized constant User::MongoMapper
        from (irb):2
irb(main):007:0>

which is right off of http://mongomapper.com/

I'm in windows 7, ruby 1.8.7 patchlevel 249. My gem list includes mongo, mongo_mapper, bson, and bson_ext (among others). I tried 'require'ing 'mongo_mapper' and/or 'mongo', and just got error messages about those 'require's.

I'm sure it's something simple, but as a ruby newbie, I'm stumped.

TIA


You have to

require "rubygems"

first on 1.8.7.

Ruby 1.9.2 automatically does it for you.

On 1.8.7 you can set an environment variable called "RUBYOPT" to do this for you. See here.

Then after you have RubyGems loaded, you can load MongoMapper and everything should work.

require "mongo_mapper"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜