From 73283f2f5153c77f72b6a29e98f173628f5e1057 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Mon, 8 Sep 2025 21:43:25 +0200 Subject: Add db seed for default Target. --- app/models/target.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/models/target.rb') 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 -- cgit v1.2.3