I have a Product model with a has_many relationship towards a Order
model. What i am trying to get is a list of all products, ordered by the
most recent Order.
For example:
Product “Old Book” was last sold on 11 November
Product “Camera Bag” was last sold on 14 November
“Old book” will be the first in the list and “Camera Bag” the second.
I have a Product model with a has_many relationship towards a Order
model. What i am trying to get is a list of all products, ordered by the
most recent Order.
For example:
Product “Old Book” was last sold on 11 November
Product “Camera Bag” was last sold on 14 November
“Old book” will be the first in the list and “Camera Bag” the second.
Join the tables and use an appropriate order clause.
I have a Product model with a has_many relationship towards a Order
model. What i am trying to get is a list of all products, ordered by the
most recent Order.
For example:
Product “Old Book” was last sold on 11 November
Product “Camera Bag” was last sold on 14 November
“Old book” will be the first in the list and “Camera Bag” the second.
Regards,
Vincent
For anyone trying to find the end result. This is what I came up with