Skip to content

Instantly share code, notes, and snippets.

Created August 28, 2014 18:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/304ac2b5cb9566774a2b to your computer and use it in GitHub Desktop.
Save anonymous/304ac2b5cb9566774a2b to your computer and use it in GitHub Desktop.
Topic.record_timestamps=false
Topic.includes(:replies).find_each do |t|
last_reply = replies.sort_by(&:created_at).last
t.replied_at = last_reply ? last_reply.created_at : t.created_at
t.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment