【发布时间】:2020-11-11 15:37:40
【问题描述】:
我有一个组合活动记录过滤器的有效解决方案,但我想知道是否可以只使用一个查询来提高性能。我尝试使用arel_tables,但尝试使用该方法组合多个查询没有成功。
我现在拥有的是这样的:
not_accepted_ids = User.where.not(status: ['accepted', 'rejected']).pluck(:id)
accepted_ids = User.where(status: 'accepted').order('updated_at DESC').limit(25).pluck(:id)
rejected_ids = User.where(status: 'rejected').order('updated_at DESC').limit(10).pluck(:id)
@users = User.where(id: not_accepted_ids + accepted_ids + rejected_ids)
提前感谢您的帮助
【问题讨论】:
标签: ruby-on-rails rails-activerecord arel