This view shows a list of authors along with the title of their newest post, but without the date that post was published. This is because it implements a Greatest Per Group query – thus, avoiding the N+1 query problem – using custom query methods, which are quite limited.
View the source code:
Read the blog post explaining this approach.
Author | Newest Post |
---|---|
J.D. Salinger | Franny and Zooey |
Jane Austen | Persuasion |
Charles Dickens | Barnaby Rudge |
This Ruby on Rails app demonstrates the concepts encompassed in a series of blog posts about Greatest Per Group queries in Rails. You can view the source code on Github.