If all you were doing was picking out the names and then ordering them, you could do this:
Code:
names = @cabinet_nominees.collect{|c| c.cabinet_pick.cabinet_position.name}
for name in names.sort
#output name
end
But I expect you want more information than just the names. The best answer depends on what information you want to retrieve. I expect, as you are collecting information from three tables, the best solution would be to use a custom SQL call. If you try joining three or more table together using standard ActiveRecord calls things really start to grind. It's usually much faster to gather all the data in a single SQL call.
Can you post your table fields and what information you want to display? It should then be possible to suggest a single SQL call that will gather all the information you want.
Bookmarks