Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update last_activity_date with random times
def make_random_time
date1 = Time.new
date2 = Time.new - 50000000 # Beginning of time range
Time.at((date2.to_f - date1.to_f) * rand + date1.to_f).to_s
end
contacts = Contact.where(...)
contacts.each { |contact| contact.update_attribute(:last_activity_date, make_random_time) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.