Skip to content

Instantly share code, notes, and snippets.

@AndreasHassing
Forked from rajputvai/gist:7889092
Last active December 30, 2015 21:39
Show Gist options
  • Save AndreasHassing/7889279 to your computer and use it in GitHub Desktop.
Save AndreasHassing/7889279 to your computer and use it in GitHub Desktop.
users = User.where('name IS NULL')
users.each do |user|
# Some api call which will retrive name of the user based on user email
name = API.getUserName user.email
if name.blank?
next
else
user.name = name
end
end
# Does this work?
users.each(&:save!)
# Has to save each user individually!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment