Rails 4 activist group

I have a table of orders and every order has a SOURCE AND ORDER TOTAL. The source is mainly order (Phone, Web, Ebay, etc.).

I want you to receive all orders and display them grouped by SOURCE and show the total for each SOURCE.

  • Phone orders - $ 1200.293
  • Web Orders - $ 1537.30
  • Ebay Orders - $ 567.00
+3


source to share


1 answer


Order.group(:source).sum(:order_total)

      



More on sum and group

+1


source







All Articles