Skip to content

Instantly share code, notes, and snippets.

@tonatiuh
Last active December 15, 2015 06:39
Show Gist options
  • Save tonatiuh/5217695 to your computer and use it in GitHub Desktop.
Save tonatiuh/5217695 to your computer and use it in GitHub Desktop.
To set the 'update_at' (the last time the user signed in) field value to the 'signed_up_at' for the users who have that field as nil.
User.where(signed_up_at: nil).each do |user|
if user.oauth_token.present? then
user.signed_up_at = user.updated_at
user.save
end
end
@daniel-g
Copy link

user.oauth_token.present?

@daniel-g
Copy link

User.where(signed_up_at: nil).where('oauth_token IS NOT NULL').update_all('signed_up_at = updated_at')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment