Finding the most recent by group in Rails
https://www.salsify.com/blog/engineering/most-recent-by-group-in-rails
A certain kind of question comes up sometimes when building an application with a relational database: What is the most recent item for each category?
This blog post walks through writing a SQL query to answer that question, and integrating the query into ActiveRecord models so that associations and eager loading work smoothly.
Post a comment