开发者

How do I get mongoid's eager loading to work?

I get the following error:

NoMethodError (undefined method `eager_load' for nil:NilC开发者_开发问答lass)

when I run the following command in Mongoid 2.2.1

Person.includes(:game).all.each do
    user.game.dosomething
end

a Person has_one Game


Just turn on Identity Map: http://mongoid.org/en/mongoid/docs/identity_map.html


Try add this to your Gemfile

# gem "mongoid-eager-loading"

But note that it's deprecated in newer mongoid versions

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜