From 7116826b854188604e21e2a613ac6672b6fd81f3 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 8 Sep 2025 21:21:56 +0200 Subject: Create Target and nutrient target table on dashboard. --- app/models/nutrient_profile.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/models/nutrient_profile.rb') diff --git a/app/models/nutrient_profile.rb b/app/models/nutrient_profile.rb index 22f2704..0610855 100644 --- a/app/models/nutrient_profile.rb +++ b/app/models/nutrient_profile.rb @@ -1,2 +1,13 @@ class NutrientProfile < ApplicationRecord + # Align these keys with your schema columns (per your schema.txt) + NUTRIENT_KEYS = %i[ + nno3 p k ca mg s na cl si fe zn b mn cu mo nnh4 + ].freeze + + # Returns a Hash of nutrient => numeric requirement (nil kept; caller can skip nils) + def requirements_hash + attributes + .slice(*NUTRIENT_KEYS.map(&:to_s)) # only nutrient columns + .transform_keys(&:to_s) + end end -- cgit v1.2.3