铁路上的热切负荷

时间:2010-08-05 23:47:05

标签: ruby-on-rails optimization

在此主题中知道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)

我不知道我是否解释......

提前致谢。

1 个答案:

答案 0 :(得分:4)

您可以通过向:include选项提供哈希来急切加载嵌套关联:

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