Hi guys, A little struct question: @events = Event.get_filtered_events(@search_term) returns a struct, but I want to call another query within a loop: for event_type in @event_types get_filtered_events_by_type(event_type.id) end and I want to add the results to the @events struct above, how do I do this? Cheers Mick -- 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 -~----------~----~----~----~------~----~------~--~---
Mick wrote:> Hi guys, > > A little struct question: > > @events = Event.get_filtered_events(@search_term) > > returns a struct, but I want to call another query within a loop: > > for event_type in @event_types > get_filtered_events_by_type(event_type.id) > end > > and I want to add the results to the @events struct above, how do I do > this? > > Cheers > > MickWhat do you mean by "struct" exactly? Do you mean a Struct described here? http://www.ruby-doc.org/core/classes/Struct.html It would make the most sense to me if Event.get_filtered_events returned an array of events. If it did then you could simply append events to the end of the array in your loop with: @event_types.each do |event_type| @events += get_filtered_events_by_type(event_type.id) end -- 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 -~----------~----~----~----~------~----~------~--~---