Created
May 4, 2016 06:17
-
-
Save pranny/691e7931e615d839492d442ef1ed85a2 to your computer and use it in GitHub Desktop.
Get variants weight in Spree
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
# Get all products in Spree | |
Spree::Product.all | |
# Get all variants of a single product | |
prod = Spree::Product.first | |
prod.variants | |
# Get the weight of a variant | |
v = prod.variants.first | |
v.weight | |
v.weight.class # BigDecimal | |
v.weight.to_i # 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment