blob: 0610855a046801682af19c0bdc8992b9f0b75733 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
|