I have a rails application and I want to know in my class Order the day that I have more creations.
Could you help me please :D I'm using as database the postgresql
Thank you in advance.
max_orders_in_a_day = Order.all.group_by{ |x| x.created_at.all_day }.sort_by { |a,b| b.length }.last
max_orders_in_a_day[0] #=> The day
max_orders_in_a_day[1] #=> An array with the related Order objects