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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
giorgio wrote:> 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?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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---