I am trying to figure this out, but haven’t had much luck searching the
forums here or google.
I have categories and items. My category model has many items, items
belong to categories, etc.
I can’t figure out how to do a find in my controller that will give me
the 5 newest items in each category.
My items table has created_at, I know how do sort on that and use :limit
=> 5, but I am not sure how to do it for each category. I feel like I
should do a Categories.find(:all) then something with each.do but I
don’t know what.
I think I could just find all of the items, then .select (for each
category) but then I have wait while I retrieve all of the items, when I
really only want a few of them.
Any ideas, or a link to a tutorial or screencast would be really
appreciated. I feel like this is something really basic, but I can’t
figure it out today.