Created
July 29, 2017 19:56
-
-
Save Epigene/85fa584773b7b1ea2594cfb49dbae95a to your computer and use it in GitHub Desktop.
Use SQL!
This file contains 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 = Post.select("MAX(id) AS last_post_id").group(:user_id) | |
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