if you need index inside the loop use (each_with_index)[http://apidock.com/ruby/Enumerable/each_with_index]