deleting associations in variable

Hi all,

Since I cannot get my records in 1 query I query more data than wanted and delete the rendundand rows afterwards. I'm trying to remove an association after I queried the database. (This association changes shouldn't be comitted to the database)

First I query the database for events and its attendees. Of some events I want to remove the attendees. I do this via 2 foreach loops (all events and all attendees in event).

I try to set the attendees to empty by event.attendees = Array.new but sometimes I get an error: RangeError: is recycled object . Also this seems to delete my records in the database!

Maybe someone has a better apporoach?

   @kinds = Kind.find(:all, :select => "distinct id, value", :conditions => {:kind => 'event'} )     events_temp = Event.find(:all, :select => :distinct, :include => :attendees, :conditions => [ "events.node_id = ?", session[:club_id]], :order => "start DESC" )     @events = Array.new     counter = 11     for event in events_temp do       if event.attendees.empty?         @events.push(event)       elsif         event.attendees.each_with_index do |attendee, index|           if (attendee.user_id == session[:user_id])             @events.push(event)           elsif (event.attendees.count == index + 1)             event.attendees = Array.new             @events.push(event)           end         end       end     end