Rails 3.0.9 and Mongo_Mapper error when using a generator

I was trying out the mongo_mapper gem with a small app that I had. I didn’t want to re-create a new app with the option to skip active-record (too easy apparently….) so instead, I converted the app to use mongo from sqlite.

After changing the application.rb to not include the whole rails/all and added the mongo_mapper gem to my Gemfile, I tried generating a new controller with the generator:

locksfree@vm0001:~/dev/rails/testapp$ rails generate controller Users new
/var/lib/gems/1.8/gems/activemodel-3.0.9/lib/active_model/translation.rb:24: uninitialized constant ActiveModel::Naming (NameError)
	from /var/lib/gems/1.8/gems/mongo_mapper-0.9.1/lib/mongo_mapper/translation.rb:4
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `const_get'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `each'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:68:in `each'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:68:in `local_constants'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:86:in `local_constant_names'
	from /var/lib/gems/1.8/gems/activemodel-3.0.9/lib/active_model/naming.rb:1
	from /var/lib/gems/1.8/gems/mongo_mapper-0.9.1/lib/mongo_mapper/plugins/active_model.rb:7
	from /var/lib/gems/1.8/gems/mongo_mapper-0.9.1/lib/mongo_mapper/embedded_document.rb:8
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `const_get'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `each'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:68:in `each'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:68:in `local_constants'
	from /var/lib/gems/1.8/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:86:in `local_constant_names'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/engine.rb:201
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/engine.rb:200:in `each'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/engine.rb:200
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `run_initializers'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `send'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
	from /home/administrator/dev/rails/tforce/config/environment.rb:5
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:103:in `require_environment!'
	from /var/lib/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:16
	from script/rails:6:in `require'
	from script/rails:6

Obviously, something didn’t go as planned. I checked and could not see anything directly wrong. The translation.rb file just used ActiveModel which should have been redefined by mongo mapper…. unless something else was redefining it before hand…

I checked the gem dependencies and only rails-3.0.9 seemed to pull in active-record, but that should not have been a problem. So, I went other the application.rb and Gemfile once more and I noticed that I hadn’t commented out the sqlite3 gem. It turned out that was just that, a nice little waste of time just there 🙂

locksfree@vm0001:~/dev/rails/testapp$ rails generate controller Users new
      create  app/controllers/users_controller.rb
       route  get "users/new"
      invoke  erb
      create    app/views/users
      create    app/views/users/new.html.erb
      invoke  rspec
      create    spec/controllers/users_controller_spec.rb
      create    spec/views/users
      create    spec/views/users/new.html.erb_spec.rb
      invoke  helper
      create    app/helpers/users_helper.rb
      invoke    rspec
      create      spec/helpers/users_helper_spec.rb

Now, to some mongo fun!

Advertisements
This entry was posted in Ruby on Rails, Web and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s