I’ve recently went back to an old project and it seems to have stopped working giving me this error:

~/projectx/vendor/ruby/1.9.1/gems/devise-2.0.0/lib/devise/rails/routes.rb:391:in `raise_no_devise_method_error!': User does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)

[read full stack trace at: gist]
Since I didn’t really change anything, I was surprised to see it break. So I tried to do what it said, I changed that I had a require statement for my ORM which was Mongoid. I had: (in config/devise.rb)

Devise.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'devise/orm/mongoid'
# ... more settings ...
end

But that wasn’t working, so I tried to move it to my config/application.rb before the definition:

# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require 'devise/orm/mongoid'

Doing that it just produced:

~/projectx/vendor/ruby/1.9.1/gems/orm_adapter-0.0.6/lib/orm_adapter/adapters/mongoid.rb:6:in `<module:ClassMethods>': uninitialized constant Mongoid::Document::ClassMethods::OrmAdapter (NameError)

[read full stack trace at: gist]
So that wasn’t getting me anywhere.

Since really neither of the errors resulted in any information that could help me, I started looking at what I can do to maybe change the issue. I tried updating the gems like devise and mongoid but that didn’t do anything. Now I wouldn’t recommend people do this but I decided to update my app from Rails 3.0 to Rails 3.2, hoping the issue gets solved with that, plus I knew this app was slated to be updated to 3.2 in the near future anyways. So I did that and it didn’t help at all. I walked away from the app for a few days because I knew pulling my hair out wouldn’t get me anywhere.

Today I looked at the app again and still had no idea what was wrong, but I looked at my Gemfile and noticed that I had  some unneeded gems for Rails 3.2. Gems like jammit, rails-3-generators and active_reload. After running ‘bundle install’ the app booted up without errors! Reinstalled the gems one by one I found out that active_reload was the reason it was happening.

If you’re getting of the errors that I was seeing and you’ve ensured that everything is setup correctly, try removing active_reload and see if that helps!

%d bloggers like this: