Complémentation

<%= link_to "Nouvelle cible", new_target_path, class: "btn btn-sm btn-outline-primary" %> <%= link_to "Liste des cibles", targets_path, class: "btn btn-sm btn-outline-secondary" %> <%= link_to "Voir la recette", root_path, class: "btn btn-sm btn-outline-secondary" %>
<% Nutrient.all.each do |nutrient| %> <% measured = @latest_measurement.send(nutrient.formula.downcase) %> <% target = @latest_target.send(nutrient.formula.downcase) %> <% delta = (target.to_f - measured.to_f) / 100.0 if measured || target %> <% end %>
Nutriment Relevé <%= @latest_target&.name || "Cible" %> Delta (%)
<%= nutrient.formula %> <%= measured.present? ? number_with_precision(measured, precision: 2) : — %> <% if target.nil? %> <% else %> <%= number_with_precision(target, precision: 2) %> <% end %> <% if measured.nil? && target.nil? %> <% else %> <% badge_class = if delta.nil? "text-bg-secondary" elsif delta.abs <= 0.01 "text-bg-success" elsif delta > 0 "text-bg-warning" else "text-bg-danger" end %> <%= number_with_precision(delta.to_f, precision: 2) %> <% end %>