I have the following models: User
, Call
.
A User
has_many
Calls
.
A Call has a column: created_at
I need to filter the users who have the most calls in the last 'x' days.
I'm here so far:
User.includes(:calls).limit(10).where("created_at > ?", Time.now - 20.days)