Hey guys/gals I have three models... Request Problem AgendaItem the request and problem are setup as has_one :agenda_item, :as => :resource and the AgendaItem is setup as belongs_to :resource, :polymorphic => true So basically I can define an agenda item as either a request or problem with the class name stored in resource_type and the id stored in resource_id in the AgendaItem table... Each item is for a specific "group". So item 1 maybe for IT and item 2 may be for DB etc etc... So here comes the question.. I need to construct a view that breaks down AgendaItem.find_all_by_show(true) by group and by resource_type... I feel that creating two array for each group (both resource types) is a bit much... Is there an easier way to itterate through the array by group in my view or something? --~--~---------~--~----~------------~-------~--~----~ 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 22 Aug 2008, at 12:28, predhme wrote:> > So here comes the question.. > > I need to construct a view that breaks down > AgendaItem.find_all_by_show(true) by group and by resource_type... I > feel that creating two array for each group (both resource types) is a > bit much... Is there an easier way to itterate through the array by > group in my view or something?I''d say that unless you''ve actually done it and it is performing unacceptably that you''re probably just worrying over an unimportant detail. Fred> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Well we have 7 groups so id be constructing 14 arrays. Plus it would be nice to know for instances when "performance" need to be optimized. On Aug 22, 8:41 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 Aug 2008, at 12:28, predhme wrote: > > > > > So here comes the question.. > > > I need to construct a view that breaks down > > AgendaItem.find_all_by_show(true) by group and by resource_type... I > > feel that creating two array for each group (both resource types) is a > > bit much... Is there an easier way to itterate through the array by > > group in my view or something? > > I''d say that unless you''ve actually done it and it is performing > unacceptably that you''re probably just worrying over an unimportant > detail. > > Fred > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 22 Aug 2008, at 16:14, predhme wrote:> > Well we have 7 groups so id be constructing 14 arrays. Plus it would > be nice to know for instances when "performance" need to be optimized. >On a multi gigahertz machine with gigs of ram 14 arrays is hardly going to matter. rails creates and dumps thousands more without you even noticing. If you can give a more concrete example of what you''re doing someone might be able to help. Fred> On Aug 22, 8:41 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 22 Aug 2008, at 12:28, predhme wrote: >> >> >> >>> So here comes the question.. >> >>> I need to construct a view that breaks down >>> AgendaItem.find_all_by_show(true) by group and by resource_type... I >>> feel that creating two array for each group (both resource types) >>> is a >>> bit much... Is there an easier way to itterate through the array by >>> group in my view or something? >> >> I''d say that unless you''ve actually done it and it is performing >> unacceptably that you''re probably just worrying over an unimportant >> detail. >> >> Fred >> >> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---