Last active
July 29, 2017 19:40
-
-
Save Epigene/498ee5753460a4c6f92f37b110213c4c to your computer and use it in GitHub Desktop.
The bad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
last_post_ids = [] | |
User.where(id: Post.all.distinct.pluck(:user_id)).find_each |user| | |
last_post_ids << user.posts.order(created_at: :desc).limit(1).pluck(:id).last | |
end | |
last_posts = Post.where(id: last_post_ids).order(created_at: :desc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment