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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---