【发布时间】:2014-10-06 15:40:24
【问题描述】:
在 Rails 应用程序中,我需要返回一个包含多列的 ActiveRecord 集合,但只有一列必须是唯一的。有一个默认范围不是唯一值。
默认范围
default_scope { order('executed_at DESC') }
当前查询没有唯一的 :terms。
Search.where(organization_id: @my_array_of_ids)
.executed_after(from_date_time)
.limit(100)
.pluck(:terms)
executed_after(from_date_time) 也是一个范围。如何在不使用 .uniq 方法的情况下更改上述查询以返回唯一术语?我希望这是一条 SQL 语句。
【问题讨论】:
标签: sql ruby-on-rails postgresql arel