I have this statement using Rails 3.2:
Event.joins(:picks).where(picks: {result: nil,created_at: 5.days.ago..Time.now,league_id: 1})
It returns what I want but with many duplicate Events.
How can I get just the unique Events?
I tried adding .distinct to the end but it returns
#<Arel::Nodes::Distinct:0x007fc13e587800>
Event
.joins(:picks)
.where(picks: {result: nil, created_at: 5.days.ago..Time.now, league_id: 1})
.group("events.id")