Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@daniel-g daniel-g commented Mar 21, 2013

user.oauth_token.present?

@daniel-g

This comment has been minimized.

Copy link

@daniel-g daniel-g commented Mar 22, 2013

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