diff options
| author | Marius Peter <dev@marius-peter.com> | 2025-11-23 17:54:45 +0100 |
|---|---|---|
| committer | Marius Peter <dev@marius-peter.com> | 2025-11-23 17:54:45 +0100 |
| commit | fa77a691ce0cc8941fe470a762f352b27f4f0563 (patch) | |
| tree | 08916174840a7896fc59633cc59fab931e7012c2 /app/models/nutrient_measurement.rb | |
| parent | 73283f2f5153c77f72b6a29e98f173628f5e1057 (diff) | |
Diffstat (limited to 'app/models/nutrient_measurement.rb')
| -rw-r--r-- | app/models/nutrient_measurement.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/nutrient_measurement.rb b/app/models/nutrient_measurement.rb index 1139af7..b56c5ed 100644 --- a/app/models/nutrient_measurement.rb +++ b/app/models/nutrient_measurement.rb @@ -1,7 +1,5 @@ class NutrientMeasurement < ApplicationRecord - NUTRIENT_FIELDS = %i[ - nno3 p k ca mg s na cl si fe zn b mn cu mo nnh4 - ].freeze + include NutrientVector validates :measured_on, presence: true validates :measured_on, uniqueness: true @@ -12,7 +10,11 @@ class NutrientMeasurement < ApplicationRecord end end - def self.nutrient_fields - NUTRIENT_FIELDS + private + + def nutrient_values + @nutrient_values ||= NutrientVector::NUTRIENT_KEYS.index_with do |k| + read_attribute(k).to_f + end end end |