2013-01-16 25 views
0

如何将limit添加到此范围?急于加载限制?

scope :with_comments, include: {comments: :user} 

我使用的是这样的:

Event.with_comments.find(params[:id]) 
+0

这可能吗? – Zeck

+1

检查这个问题,你会得到你的答案http://stackoverflow.com/questions/9808674/rails-eager-load-and-limit – SSP

回答

2
scope :with_comments, include(comments: :user).limit(5) 
0
default_scope includes(:comments :user).limit(5) 

添加到默认范围

Event.find(params[:id])