Jan de Jager
Jan de Jager

Reputation: 870

mongoid NoMethodError (undefined method `all' for Complex:Class)

I'm new to rails... Simple scaffold of a mongoid model is throwing NoMethodError.

class code:

class Complex
    include Mongoid::Document

    field :name, type: String
end

controller code:

def index
    @complexes = Complex.all #this is the offending line?
end

GEMFILE (extract):

...
gem 'rails', '4.0.2'
gem 'mongoid', github: 'mongoid/mongoid'
...

Upvotes: 0

Views: 578

Answers (1)

Jaffa
Jaffa

Reputation: 12719

In ruby (at least >= 1.8.6) Complex is a class defined by the language, so when you reference Complex.all it looks for the class defined in complex.c in the ruby source code instead of your class.

Upvotes: 1

Related Questions