Skip to content

Instantly share code, notes, and snippets.

@enajski
Created March 3, 2014 11:32
Show Gist options
  • Save enajski/9323206 to your computer and use it in GitHub Desktop.
Save enajski/9323206 to your computer and use it in GitHub Desktop.
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