Topic: Order through association

Hi guys

I have current_user which has_many: events

An event has_many :event_dates

Currently I can do current_user.events

Which shows me all the events I have been Invited through, via the Invitation model.

Now, on the dashboard I only want to get Events.where the event_dates 'date' is today or in the future.

I've tried doing..

@events = current_user.events.where('events.event_dates.date >= ?, Date.today')

I'm just now sure if I'm on the right track or miles off!

Any help would be much appreciated!

Thanks guys smile

Re: Order through association

Almost smile

current_user.events.joins(:event_dates).where("event_dates.date >= ?", Date.today)