How to Determine if Rails Association is Eager Loaded?

前端 未结 7 1297
后悔当初
后悔当初 2021-01-30 16:02

Does anyone know a way to determine if a Rails association has been eager loaded?

My situation: I have a result set where sometimes one of the associations is eager l

7条回答
  •  醉梦人生
    2021-01-30 16:29

    association_cached? might be a good fit:

    item.association_cached?(:shipping_infos)
    

提交回复
热议问题