0

如何将 a 添加limit到此范围?

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

我这样使用它:

Event.with_comments.find(params[:id])
4

2 回答 2

2
scope :with_comments, include(comments: :user).limit(5)
于 2013-01-16T07:56:52.410 回答
0
default_scope includes(:comments :user).limit(5)

将其添加到默认范围

Event.find(params[:id])
于 2013-01-16T08:52:32.550 回答