Moved Formula to separate model
This commit is contained in:
@@ -11,7 +11,6 @@ class CreateSchema < ActiveRecord::Migration
|
||||
t.references :project
|
||||
t.integer :domain
|
||||
t.string :name
|
||||
t.string :formula
|
||||
t.string :description
|
||||
# fields for awesome_nested_set
|
||||
t.references :parent
|
||||
@@ -20,6 +19,13 @@ class CreateSchema < ActiveRecord::Migration
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :formulas do |t|
|
||||
t.references :quantity
|
||||
t.string :code
|
||||
t.boolean :zero_nil
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :column_views do |t|
|
||||
t.references :project
|
||||
t.string :name
|
||||
|
||||
@@ -138,7 +138,7 @@ class LoadDefaults < ActiveRecord::Migration
|
||||
# Calculated quantities go at the and to make sure dependencies exist
|
||||
e2 = Quantity.create project: nil, domain: :diet, parent: e1, name: "Calculated",
|
||||
description: "Total energy calculated from macronutrients",
|
||||
formula: "4*(Proteins || 0) + 9*(Fats || 0) + 4*(Carbohydrates || 0)"
|
||||
formula_attributes: {code: "4*Proteins + 9*Fats + 4*Carbohydrates", zero_nil: true}
|
||||
|
||||
Source.create project: nil, name: "nutrition label",
|
||||
description: "nutrition facts taken from package nutrition label"
|
||||
|
||||
Reference in New Issue
Block a user