Reputation: 3192
I have this piece of code
<% @hours.joins(:worker).order('workers.name').each do |hour| %>
<tr>
<td><%= hour.worker.name %></td>
<td><%= hour.job.date</td>
...
How can do an order on the hour.job.date after being sorted on worker.name?
Upvotes: 0
Views: 48
Reputation: 52377
Just specify the columns you want to order by (in your case you'll want to join jobs
table as well):
@hours.joins(:worker, :job).order('workers.name, jobs.date')
Upvotes: 1