I'm trying to get the projects sorted by the total price of their respective items. Something like:
Project.includes(:items).order('SUM(items.price)')
With this code, ActiveRecord returns only the first project. What am I missing?
I've not tried the v3 stuff out yet, but I'd assume it would be something like
Product.joins(:items).group('products.id').order('SUM(items.price)')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With