Gareth Adams
2006-Sep-18 13:17 UTC
using :group, :having, :select etc with eager loading through :include
I''m sure I''ve seen this on the list before, but I can''t find anything in the search. The problem is that using :include in an ActiveRecord::Base#find aliases all the columns, making it impossible to use some of the other find parameters What''s the usual solution to this? Gareth --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2006-Sep-19 11:41 UTC
Re: using :group, :having, :select etc with eager loading through :include
Gareth Adams wrote:> I''m sure I''ve seen this on the list before, but I can''t find anything in the > search. > > The problem is that using :include in an ActiveRecord::Base#find aliases all > the columns, making it impossible to use some of the other find parameters > > What''s the usual solution to this?You will have to forgo eager loading and either load the records of the other models in separate queries, or use the :joins and :select options to pull fields of interest in the other models into the base model. -- 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 -~----------~----~----~----~------~----~------~--~---