在这个线程中知道how to make a eager load in rails ,但是如何嵌套?
即:
# get category, random product and random photo
@category = Category.find(params[:id], :include => random_product, :include => random_photo)
我不知道我是否解释...
提前致谢。
请您参考如下方法:
您可以通过为 :include 选项提供哈希值来预先加载嵌套关联:
@category = Category.find(params[:id], :include => { :random_product => :random_photo})

