I'm attempting to do a SQL sort in rails by sorting on a column in multiple tables.
Both Event and Featured models have a column called "date". An event can belong_to a Featured. I'd like to be able to join these two columns together and sort by this date column on both. So if the date of a Featured is 24/05/12 and the date of an Event is 23/05/12, then the Event date would display first.
I'd prefer to do this in SQL (not using a Ruby sort).
Thanks!
Edit:
.order("events.date ASC, featureds.date ASC")
Will not work because this will pull back first the events in order, then the featureds in order.
For example:
Event 1 date: 23/04/12
Event 2 date: 24/04/12
Featured 1 date: 23/04/12
What I want the sql to pull back is:
Event 1 date: 23/04/12
Featured 1 date: 23/04/12
Event 2 date: 24/04/12
Ordering like above will pull it through like so:
Event 1 date: 23/04/12
Event 2 date: 24/04/12
Featured 1 date: 23/04/12