I added an include to a find statement in order to preload data rather than using lazy loading eg.Client.find(params[:id],:include=>[:contacts, :etc,:etc]) I have a sort clause in the Client model eg has_many :contacts, :order=>"contact_date" The sort works fine when listing Client.contacts in a view, but as soon as I do the include to preload the sort order is lost. Is there any simple way around this apart from removing the include? Cheers George
on 2007-06-25 07:01
on 2007-06-25 11:36
You might have to sort the contacts after you've got them using Array#sort. I'm not sure if MySQL allows for the sorting of joined rows. I've googled but I don't see anything.
on 2007-06-25 20:26
giorgio wrote: > Is there any simple way around this apart from removing the include? Client.find params[:id], :include=>[:contacts, :etc, :etc], :order => 'contacts.contact_date' should work. -- We develop, watch us RoR, in numbers too big to ignore.