K2xL
K2xL

Reputation: 10340

Mongoid Errors When Doing Model.first

I just upgraded to Mongoid 3, but I'm having a very strange issue.

I have a model called "Event" and another called "Team" - each has has_and_belongs_to_many relationship.

After upgrading, I simply can't do Event.first or Event.last on the console. I get this error in the console:

undefined method `each' for nil:NilClass

The error occurs in set_on_parent in mongoid (4.0.0.alpha1) lib/mongoid/relations/eager/base.rb

What's strange is that Team.first (and all my other models) work fine.

Upvotes: 1

Views: 58

Answers (1)

K2xL
K2xL

Reputation: 10340

Turns out in my Event class I had a default_scope includes(:teams). Removing that cleared up the error.

Upvotes: 1

Related Questions