【发布时间】:2013-09-29 16:05:21
【问题描述】:
我知道我可以对 has_many :through 中的关联应用限制,即:
class Post
has_many :commenters, through: :comments, uniq: true, limit: 10
end
这将返回最多 10 个commenters。但是,如果我只想知道贡献了前 10 个 cmets 的人怎么办? (例如,如果有一个乒乓评论线程,它只会产生 2 个结果)。换句话说,我如何限制这个查询中comments的数量?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 activerecord associations has-many-through