From c0e3fd2e85debf4153479c82ec5e1587728f9f0e Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Tue, 22 Oct 2019 23:19:58 +0200 Subject: [PATCH] Changed Quantity.displayed -> Quantity.primary --- app/controllers/body_trackers_controller.rb | 2 +- app/controllers/ingredients_controller.rb | 2 +- app/models/quantity.rb | 2 +- db/migrate/001_create_units.rb | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/body_trackers_controller.rb b/app/controllers/body_trackers_controller.rb index fc3e03c..4428b54 100644 --- a/app/controllers/body_trackers_controller.rb +++ b/app/controllers/body_trackers_controller.rb @@ -27,7 +27,7 @@ class BodyTrackersController < ApplicationController parent: q.parent ? available[[q.parent.name, q.parent.domain]] : nil, name: q.name, description: q.description, - displayed: q.displayed + primary: q.primary }) available[[q.name, q.domain]] = obj end diff --git a/app/controllers/ingredients_controller.rb b/app/controllers/ingredients_controller.rb index 383cf46..d335cd6 100644 --- a/app/controllers/ingredients_controller.rb +++ b/app/controllers/ingredients_controller.rb @@ -135,7 +135,7 @@ class IngredientsController < ApplicationController def nutrients 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] = {} } @descriptions = Hash.new { |h,k| h[k] = [] } ingredients.each do |i| diff --git a/app/models/quantity.rb b/app/models/quantity.rb index 9e755ff..a56f2aa 100644 --- a/app/models/quantity.rb +++ b/app/models/quantity.rb @@ -16,7 +16,7 @@ class Quantity < ActiveRecord::Base after_initialize do if new_record? - self.displayed = false if self.displayed.nil? + self.primary = false if self.primary.nil? end end end diff --git a/db/migrate/001_create_units.rb b/db/migrate/001_create_units.rb index acae5c7..6516bca 100644 --- a/db/migrate/001_create_units.rb +++ b/db/migrate/001_create_units.rb @@ -11,7 +11,7 @@ class CreateUnits < ActiveRecord::Migration t.string :name t.string :description t.integer :domain - t.boolean :displayed + t.boolean :primary # fields for awesome_nested_set t.references :parent 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/legislation/food_legislation/food_information_fic/nutrition_labelling.html 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", - 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", - 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", description: "" f2 = Quantity.create project: nil, domain: :diet, parent: f1, name: "Saturated", @@ -87,7 +87,7 @@ class CreateUnits < ActiveRecord::Migration description: "Docosahexaenoic acid" 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", description: "" c3 = Quantity.create project: nil, domain: :diet, parent: c2, name: "Sugars",