diff options
author | Marius Peter <dev@marius-peter.com> | 2025-09-08 21:43:25 +0200 |
---|---|---|
committer | Marius Peter <dev@marius-peter.com> | 2025-09-08 21:43:25 +0200 |
commit | 73283f2f5153c77f72b6a29e98f173628f5e1057 (patch) | |
tree | af0098a91115852449c51a2929d471acf3a9f568 /app/models | |
parent | 7116826b854188604e21e2a613ac6672b6fd81f3 (diff) |
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/target.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/models/target.rb b/app/models/target.rb index 3063b42..9211e74 100644 --- a/app/models/target.rb +++ b/app/models/target.rb @@ -4,7 +4,7 @@ class Target < ApplicationRecord has_many :nutrient_profiles, through: :target_allocations accepts_nested_attributes_for :target_allocations, allow_destroy: true - validate :percentages_sum_to_100 + # validate :percentages_sum_to_100 def weighted_requirements totals = Hash.new(0.0) @@ -35,8 +35,8 @@ class Target < ApplicationRecord private - def percentages_sum_to_100 - sum = target_allocations.reject(&:marked_for_destruction?).sum { |a| a.percentage.to_f } - errors.add(:base, "La somme des pourcentages doit être égale à 100%") unless (sum - 100.0).abs <= 0.01 - end + # def percentages_sum_to_100 + # sum = target_allocations.sum { |a| a.percentage.to_f } + # errors.add(:base, "La somme des pourcentages doit être égale à 100%") unless (sum - 100.0).abs <= 0.1 + # end end |