Updated energy formula to accept nils
This commit is contained in:
parent
b437bee18b
commit
80dac0dc9d
@ -138,7 +138,7 @@ class LoadDefaults < ActiveRecord::Migration
|
|||||||
# Calculated quantities go at the and to make sure dependencies exist
|
# Calculated quantities go at the and to make sure dependencies exist
|
||||||
e2 = Quantity.create project: nil, domain: :diet, parent: e1, name: "Calculated",
|
e2 = Quantity.create project: nil, domain: :diet, parent: e1, name: "Calculated",
|
||||||
description: "Total energy calculated from macronutrients",
|
description: "Total energy calculated from macronutrients",
|
||||||
formula: "4*Proteins + 9*Fats + 4*Carbohydrates"
|
formula: "4*(Proteins || 0) + 9*(Fats || 0) + 4*(Carbohydrates || 0)"
|
||||||
|
|
||||||
Source.create project: nil, name: "nutrition label",
|
Source.create project: nil, name: "nutrition label",
|
||||||
description: "nutrition facts taken from package nutrition label"
|
description: "nutrition facts taken from package nutrition label"
|
||||||
|
Reference in New Issue
Block a user