Created
December 13, 2016 08:49
-
-
Save alekseyl/69d9c5f632099a6fe37de2e8fbc422c1 to your computer and use it in GitHub Desktop.
virtual attributes example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DB way | |
Shipment.scope | |
.joins(purchase: :product) | |
.select(["shipments.*","sum(purchases.items_count*products.gross_weight) as gross_weight"]) | |
.group("shipments.id") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment