开发者

How do I update a sequential attribute with foobar#{n} with n incrementing?

I want to write basically

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

How do I make that #{incre开发者_StackOverflowmenting_number} incremement per updated attribute.

:D


Enumerable#each_with_index

User.find(:all).each_with_index {|u,i| u.update_attribute("email","nil#{i}")}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜