I have a rails 3 app that has models like categories and posts.
Category
has_many :posts
Post
belongs_to :category
I want to be able to display a list of categories with the most recent post listed next to it without looping through and hitting the database for each category and only pulling back one post per category.
I want to do the same thing this question poses - SQL join: selecting the last records in a one-to-many relationship - but hopefully using Active Record.
Is this a dumb thing to be doing? Should I just pull back all the posts for a category by eager loading them? I was concerned about performance, which is why I started researching this.