Skip to content

Instantly share code, notes, and snippets.

@yangxing-star
Created April 3, 2014 04:46
Show Gist options
  • Save yangxing-star/9948417 to your computer and use it in GitHub Desktop.
Save yangxing-star/9948417 to your computer and use it in GitHub Desktop.
替换大使PK头像
l=Leaderboard.find('530fe34025d9803aa5001a68')
l.users.each do |uid, u|
user = {}
referring = {}
user[:nickname] = u[:nickname]
user[:avatar_url] = User.find(uid).avatar.url('58x58')
user[:city] = u[:city]
user[:referred_at] = u[:referred_at]
u[:referring].each do |k, v|
hash = {}
hash[:nickname] = v[:nickname]
hash[:avatar_url] = User.find(k).avatar.url('58x58')
hash[:city] = u[:city]
hash[:referred_at] = u[:referred_at]
referring[k] = hash
end
user[:referring] = referring
l.users[uid] = user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment