views:

23

answers:

1

I want to write basically

User.find(:all).each {|u| u.update_attribute("email","nil#{incrementing_number}")}

How do I make that #{incrementing_number} incremement per updated attribute.

:D

+2  A: 

Enumerable#each_with_index

User.find(:all).each_with_index {|u,i| u.update_attribute("email","nil#{i}")}
Justin L.
You are enumerably genius.
Trip