[Rails] Fertilizer recipe solver for the FAPG.
1
classNutrientProfile<ApplicationRecord
2
# Align these keys with your schema columns (per your schema.txt)
3
NUTRIENT_KEYS = %i[
4
nno3 p k ca mg s na cl si fe zn b mn cu mo nnh4
5
].freeze
6
7
# Returns a Hash of nutrient => numeric requirement (nil kept; caller can skip nils)
8
def requirements_hash
9
attributes
10
.slice(*NUTRIENT_KEYS.map(&:to_s)) # only nutrient columns
11
.transform_keys(&:to_s)
12
end
13
end
14