Skip to content

Instantly share code, notes, and snippets.

@Epigene Epigene/the ok.rb
Created Jul 29, 2017

What would you like to do?
Use SQL!
last_post_ids ="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
You can’t perform that action at this time.