Skip to content

Instantly share code, notes, and snippets.

@AndyMoreland
Created February 15, 2010 06:17
Show Gist options
  • Select an option

  • Save AndyMoreland/304451 to your computer and use it in GitHub Desktop.

Select an option

Save AndyMoreland/304451 to your computer and use it in GitHub Desktop.
NoMethodError in Blog postsController#index
undefined method `devise' for User:Class
All of the configuration is by the book. Nothing special, just defaults.
Everything in the app works except for the user model -- other models are just fine.
The mongoid.rb file is being loaded by devise correctly. It seems that the Devise::Models module is never being included into Mongoid::Document::ClassMethods
I have not defined any field on the user model, just trying to get Devise to load first.
Using bundler to manage gems, rails 2.3.5.
module Devise
module Orm
module Mongoid
def self.included_modules_hook(klass, modules)
klass.send :extend, self
yield
modules.each do |mod|
klass.send(mod) if klass.respond_to?(mod)
end
end
include Devise::Schema
# Tell how to apply schema methods. This automatically converts DateTime
# to Time, since MongoMapper does not recognize the former.
def apply_schema(name, type, options={})
return unless Devise.apply_schema
type = Time if type == DateTime
field name, {:type => type}.merge(options)
end
end
end
end
Mongoid::Document::ClassMethods.send(:include, Devise::Models)
class User
include Mongoid::Document
devise :authenticatable
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment