开发者

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

开发者 https://www.devze.com 2023-01-16 16:40 出处:网络
Iwant to write basically User.find(:all).each {|u| u.update_attribute(\"email\",\"nil#{incrementing_number}\")}

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

精彩评论

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