【发布时间】:2015-07-27 16:31:18
【问题描述】:
我的查询可能有问题,不确定到底是什么...
# this is the correct output
Plan.select { |p| p.plan_dates.select { |pd| pd.ddate.to_date >= cancel_from_this_date }.count > 0 }.map(&:id)
# => [54]
# this is the output where the object is returned twice
Plan.joins(:plan_dates).where("plan_dates.ddate >= ?", cancel_from_this_date.in_time_zone).pluck("id")
# => [54, 54]
【问题讨论】:
标签: sql ruby-on-rails ruby-on-rails-4 activerecord