I''m trying to order my results by what I got with eager loading. there is a bit of code about what i want @study_class = StudyClass.find(:all, :include => :teacher) it is associated with an id, and i want to order my result by the teachers'' name, which is just inside the teacher table that is loaded there. is it possible or will i have to reorder it with ruby code? thanks! -- gallois aka Felipe Gallois blog: www.gallois.com.br/blog fanglib homepage: www.gallois.com.br/fanglib --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> > is it possible or will i have to reorder it with ruby code? >Can be done like that: @study_class = StudyClass.find(:all, :include => :teacher, :order => "teachers.name ASC") (since :order takes pure SQL, it must be the table name in plural as used in the database) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 19 Nov 2008, at 01:05, Felipe Gallois wrote:> I''m trying to order my results by what I got with eager loading. > > there is a bit of code about what i want > > @study_class = StudyClass.find(:all, :include => :teacher) > > it is associated with an id, and i want to order my result by the > teachers'' name, which is just inside the teacher table that is > loaded there. > > is it possible or will i have to reorder it with ruby code?:order => ''teachers.something'' Fred> > > thanks! > > -- > gallois > aka Felipe Gallois > blog: www.gallois.com.br/blog > fanglib homepage: www.gallois.com.br/fanglib > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Wed, Nov 19, 2008 at 07:26, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > On 19 Nov 2008, at 01:05, Felipe Gallois wrote: > > > I''m trying to order my results by what I got with eager loading. > > > > there is a bit of code about what i want > > > > @study_class = StudyClass.find(:all, :include => :teacher) > > > > it is associated with an id, and i want to order my result by the > > teachers'' name, which is just inside the teacher table that is > > loaded there. > > > > is it possible or will i have to reorder it with ruby code? > > :order => ''teachers.something'' > > Fred > > > > > > thanks! > > > > -- > > gallois > > aka Felipe Gallois > > blog: www.gallois.com.br/blog > > fanglib homepage: www.gallois.com.br/fanglib > > > > > > > > > >perfect! worked like a charm! thank you very much guys! cheers! -- gallois aka Felipe Gallois blog: www.gallois.com.br/blog fanglib homepage: www.gallois.com.br/fanglib --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---