got a loop to work in rails