How to perform eager loading in active_model_serializers

天涯浪子 提交于 2019-12-03 21:43:26
Jeff Ancel

This is a good description and explanation. This is what you're looking for?

class ModelName
  default_scope includes(:other)
end

How to add `:include` to default_scope?

Edit:

I haven't done this in a nest of models like you have, I have done this through one level using serializers, and I've also used jbuilder to ease the pain and leverage control through 2 levels. I still believe you want to put this layer of control on the model level though.

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