Adding to a struct

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

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

Mick

What do you mean by “struct” exactly? Do you mean a Struct described
here? class Struct - RDoc Documentation

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