RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

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

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in