MongoMapper won't let me create an object

Posted by Jade on Stack Overflow See other posts from Stack Overflow or by Jade
Published on 2010-03-28T03:46:07Z Indexed on 2010/03/28 3:53 UTC
Read the original article Hit count: 416

Filed under:
|

I'm just learning MongoDB and MongoMapper. This is on Rails 3.

I created a blog in app/models/blog.rb:

class Blog
  include MongoMapper::Document

  key :title, String, :required => true
  key :body, Text
  timestamps!
end

I go into the Rails console:

rails c

Loading development environment (Rails 3.0.0.beta)
ruby-1.9.1-p378 > **b = Blog.new**
NoMethodError: undefined method `from_mongo' for Text:Module
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/keys.rb:323:in `get'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/keys.rb:269:in `read_key'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/keys.rb:224:in `[]'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/inspect.rb:7:in `block in inspect'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/inspect.rb:6:in `collect'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/mongo_mapper-0.7.2/lib/mongo_mapper/plugins/inspect.rb:6:in `inspect'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta/lib/rails/commands/console.rb:47:in `start'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta/lib/rails/commands/console.rb:8:in `start'
    from /Users/jade/.rvm/gems/ruby-1.9.1-p378/gems/railties-3.0.0.beta/lib/rails/commands.rb:34:in `<top (required)>'
    from /Users/jade/code/farmerjade/script/rails:10:in `require'
    from /Users/jade/code/farmerjade/script/rails:10:in `<main>'

Am I overlooking something really dumb, or is this something in my setup?

I'm using the mongo_mapper version you get by adding it to your Gemfile, so I'm wondering if it might be that. I'd appreciate any suggestions!

© Stack Overflow or respective owner

Related posts about mongomapper

Related posts about ruby-on-rails3