Starting with Ruby 1.9, you can use map.with_index:
:participants => item.item_participations.map.with_index { |item, idx| {:item_image => item.user.profile_pic.url(:small)} break if i == 2 }
Although I prefer the method proposed by justice.
Brian deterling
source share