Hi, I''m new in Ruby on Rails and I don''t know how can I achive something like this: @switchs = Switch.find(:all) for switch in @switchs if current_user.shifts.count(:all,:conditions=>["date = ? and shift = ?",switch.destiny_date, switch.destiny_turn]) !=0 @valid = switch @valid.merge(cambio) end end return @valid Let me explain. I just want to put in the same @valid object, switchs that satisfy the "if" condition. So, I have to loop for every switch and just select those ones that satisfy the condition. Is there any way to achieve this??? Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---