Changed Quantity.displayed -> Quantity.primary
This commit is contained in:
parent
9578de8287
commit
c0e3fd2e85
@ -27,7 +27,7 @@ class BodyTrackersController < ApplicationController
|
|||||||
parent: q.parent ? available[[q.parent.name, q.parent.domain]] : nil,
|
parent: q.parent ? available[[q.parent.name, q.parent.domain]] : nil,
|
||||||
name: q.name,
|
name: q.name,
|
||||||
description: q.description,
|
description: q.description,
|
||||||
displayed: q.displayed
|
primary: q.primary
|
||||||
})
|
})
|
||||||
available[[q.name, q.domain]] = obj
|
available[[q.name, q.domain]] = obj
|
||||||
end
|
end
|
||||||
|
@ -135,7 +135,7 @@ class IngredientsController < ApplicationController
|
|||||||
|
|
||||||
def nutrients
|
def nutrients
|
||||||
ingredients = @project.ingredients.includes(:ref_unit, nutrients: [:quantity, :unit])
|
ingredients = @project.ingredients.includes(:ref_unit, nutrients: [:quantity, :unit])
|
||||||
@header = @project.quantities.where(displayed: true)
|
@header = @project.quantities.where(primary: true)
|
||||||
@nutrients = Hash.new { |h,k| h[k] = {} }
|
@nutrients = Hash.new { |h,k| h[k] = {} }
|
||||||
@descriptions = Hash.new { |h,k| h[k] = [] }
|
@descriptions = Hash.new { |h,k| h[k] = [] }
|
||||||
ingredients.each do |i|
|
ingredients.each do |i|
|
||||||
|
@ -16,7 +16,7 @@ class Quantity < ActiveRecord::Base
|
|||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
if new_record?
|
if new_record?
|
||||||
self.displayed = false if self.displayed.nil?
|
self.primary = false if self.primary.nil?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ class CreateUnits < ActiveRecord::Migration
|
|||||||
t.string :name
|
t.string :name
|
||||||
t.string :description
|
t.string :description
|
||||||
t.integer :domain
|
t.integer :domain
|
||||||
t.boolean :displayed
|
t.boolean :primary
|
||||||
# fields for awesome_nested_set
|
# fields for awesome_nested_set
|
||||||
t.references :parent
|
t.references :parent
|
||||||
t.integer :lft, :null => false, :index => true
|
t.integer :lft, :null => false, :index => true
|
||||||
@ -54,13 +54,13 @@ class CreateUnits < ActiveRecord::Migration
|
|||||||
# https://www.fsai.ie/uploadedFiles/Consol_Reg1169_2011.pdf
|
# https://www.fsai.ie/uploadedFiles/Consol_Reg1169_2011.pdf
|
||||||
# https://www.fsai.ie/legislation/food_legislation/food_information_fic/nutrition_labelling.html
|
# https://www.fsai.ie/legislation/food_legislation/food_information_fic/nutrition_labelling.html
|
||||||
e = Quantity.create project: nil, domain: :diet, parent: nil, name: "Energy",
|
e = Quantity.create project: nil, domain: :diet, parent: nil, name: "Energy",
|
||||||
description: "Total energy", displayed: true
|
description: "Total energy", primary: true
|
||||||
|
|
||||||
Quantity.create project: nil, domain: :diet, parent: nil, name: "Proteins",
|
Quantity.create project: nil, domain: :diet, parent: nil, name: "Proteins",
|
||||||
description: "Total amount of proteins", displayed: true
|
description: "Total amount of proteins", primary: true
|
||||||
|
|
||||||
f = Quantity.create project: nil, domain: :diet, parent: nil, name: "Fats",
|
f = Quantity.create project: nil, domain: :diet, parent: nil, name: "Fats",
|
||||||
description: "Total lipids, including phospholipids", displayed: true
|
description: "Total lipids, including phospholipids", primary: true
|
||||||
f1 = Quantity.create project: nil, domain: :diet, parent: f, name: "Fatty acids",
|
f1 = Quantity.create project: nil, domain: :diet, parent: f, name: "Fatty acids",
|
||||||
description: ""
|
description: ""
|
||||||
f2 = Quantity.create project: nil, domain: :diet, parent: f1, name: "Saturated",
|
f2 = Quantity.create project: nil, domain: :diet, parent: f1, name: "Saturated",
|
||||||
@ -87,7 +87,7 @@ class CreateUnits < ActiveRecord::Migration
|
|||||||
description: "Docosahexaenoic acid"
|
description: "Docosahexaenoic acid"
|
||||||
|
|
||||||
c1 = Quantity.create project: nil, domain: :diet, parent: nil, name: "Carbohydrates",
|
c1 = Quantity.create project: nil, domain: :diet, parent: nil, name: "Carbohydrates",
|
||||||
description: "Total amount of carbohydrates", displayed: true
|
description: "Total amount of carbohydrates", primary: true
|
||||||
c2 = Quantity.create project: nil, domain: :diet, parent: c1, name: "Digestible",
|
c2 = Quantity.create project: nil, domain: :diet, parent: c1, name: "Digestible",
|
||||||
description: ""
|
description: ""
|
||||||
c3 = Quantity.create project: nil, domain: :diet, parent: c2, name: "Sugars",
|
c3 = Quantity.create project: nil, domain: :diet, parent: c2, name: "Sugars",
|
||||||
|
Reference in New Issue
Block a user