Mongoid: How to load only some fields of an object you lazy load via reference?

*爱你&永不变心* 提交于 2019-12-01 15:32:22

Answer from creator of Mongoid. It's not possible yet. It's been added as feature request.

I think you need to denormalize here. First of all, read A Note on Denormalization.

You can implement denormalization by self using mongoid events or use great mongoid_denormalize gem. It pretty straight and after implementing it you could use p.user_email or something in your queries.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!