I have this table where I count the number of reservations for each product. I would like to have these counts in descending order. How could I go about it?
Product.joins(
Product.arel_table.join(Reservation.arel_table, Arel::Nodes::OuterJoin).on(
Reservation.arel_table[:product_id].eq(Product.arel_table[:id])
).join_sources
).group(Product.arel_table[:id]).select(Product.arel_table[Arel.star],
Reservation.arel_table[:id].count.as('res_count'))