Re: [MongoMapper] trouble upgrading to ruby 1.9.2, using MM 0.8.6

66 views
Skip to first unread message

John Nunemaker

unread,
Aug 21, 2012, 9:10:12 PM8/21/12
to mongo...@googlegroups.com
0.8.6 only supports rails 2.x. You need to upgrade to get rails 3.x support.

On Tue, Aug 21, 2012 at 6:21 PM, marcel <mpo...@gmail.com> wrote:
I'm in the process of upgrading an old project to use ruby 1.9.2 (so I can run it on the Cedar stack at Heroku). I ran into a number of issues, so I decided to bump my Rails version from 2.3.8 to 2.3.14. That fixed a lot of things and thin starts up. But when I request a page, I get a crash from MongoMapper.

I'm using mongo_mapper v0.8.6, since I read somewhere that is the latest version that runs on Rails 2.x

NameError (uninitialized constant MongoMapper::Plugins::Caching::ClassMethods):
  /Users/marcel/.rvm/gems/ruby-1.9.2-p320@btw/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:212:in `const_missing_from_s3_library'
  rake (0.9.2.2) lib/rake/ext/module.rb:36:in `const_missing'
  /Users/marcel/.rvm/gems/ruby-1.9.2-p320@btw/gems/mongo_mapper-0.8.6/lib/mongo_mapper/plugins.rb:9:in `plugin'
  /Users/marcel/.rvm/gems/ruby-1.9.2-p320@btw/gems/mongo_mapper-0.8.6/lib/mongo_mapper/document.rb:13:in `block in included'
  /Users/marcel/.rvm/gems/ruby-1.9.2-p320@btw/gems/mongo_mapper-0.8.6/lib/mongo_mapper/document.rb:7:in `class_eval'
  /Users/marcel/.rvm/gems/ruby-1.9.2-p320@btw/gems/mongo_mapper-0.8.6/lib/mongo_mapper/document.rb:7:in `included'


Thanks,
Marcel

--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en

marcel

unread,
Aug 22, 2012, 1:58:27 PM8/22/12
to mongo...@googlegroups.com
I'm on rails 2.x (2.3.14), which is why I'm using MM 0.8.6.

Anyway I think I figured out the problem.

In lib/mongo_mapper/plugins.rb#plugin, calls to const_defined? need to be passed 'false'.

# encoding: UTF-8
module MongoMapper
  module Plugins
    def plugins
      @plugins ||= []
    end

    def plugin(mod)
      extend mod::ClassMethods     if mod.const_defined?(:ClassMethods, false)
      include mod::InstanceMethods if mod.const_defined?(:InstanceMethods, false)
      mod.configure(self)          if mod.respond_to?(:configure)
      plugins << mod
    end
  end
end

Justin Dossey

unread,
Aug 22, 2012, 2:33:58 PM8/22/12
to mongo...@googlegroups.com
Marcel,

You're aware that Rails 2.3.14 does not officially support Ruby 1.9.x, right?  Some people have gotten it to work with monkey-patching, but you're going to be clearing a path with every gem you wish to support (including MongoMapper).

Justin Dossey

Jamie Orchard-Hays

unread,
Aug 22, 2012, 2:37:01 PM8/22/12
to mongo...@googlegroups.com
When I wanted to upgrade several Rails 2.3.x apps to Rails 3.x and Ruby 1.9.x, I figured I'd upgrade Ruby first. It was full of problems, so I decided to go with Rails upgrade first. It's a PITA, but you really will have to upgrade Rails to 3.x first if you want Ruby 1.9.x

If your rails app is largish, be prepared for a slog.

Marcel Poisot

unread,
Aug 22, 2012, 2:52:08 PM8/22/12
to mongo...@googlegroups.com
I wasn't aware of the Rails 2.x / Ruby 1.9 conflict until today... My app is huge and uses tons of old gems. Looks like I either need to do a rewrite or go through upgrade hell.

Jamie Orchard-Hays

unread,
Aug 22, 2012, 3:02:09 PM8/22/12
to mongo...@googlegroups.com
I hate to say it, but if it's a huge Rails app, it might be better to start with a new Rails 3 app and incrementally bring over pieces of the old app at a time rather than try to upgrade the whole thing. I had a medium-to-large Rails app that took several weeks of work to upgrade. It's not trivial. The ERb tag changes alone will keep you busy making sure you've found them all. :-)

Gary Murakami

unread,
Aug 22, 2012, 3:13:00 PM8/22/12
to mongo...@googlegroups.com
Also make sure to learn about and experience Rails 3 routes before you try your upgrade, or you probably will be forced to stop and learn about Rails 3 routes mid-stream.  rake routes is your friend.
Reply all
Reply to author
Forward
0 new messages