Reputation: 1380
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
Upvotes: 2
Views: 1718
Reputation: 539
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"
Upvotes: 2