updates = [] #updates,inserts = items.partition { |e| @items.each { |x| x['key'] == e['key'] } } items.each do |x| @items.each do |y| if y['key'] == x['key'] updates << x items.delete x end end end inserts = items