开发者

Deep eager load on rails

In this thread know how to make a eager load in rails, but how to do this nested?

I.e:

# get category, random product and random photo
@开发者_如何学Ccategory = Category.find(params[:id], :include => random_product, :include => random_photo)

I don't know if I explain...

Thanks in advance.


You can eager load nested associations by giving a hash to the :include option:

@category = Category.find(params[:id], :include => { :random_product => :random_photo})
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜