From 65def47ead70bf95d63b4f4db9f3cb556cf22855 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 13:41:31 +0000 Subject: [PATCH] Fix: Correct nutrition data rendering and add AFCD name This commit addresses two issues in the nutritional data view: 1. **Fixes String Interpolation:** The HAML template incorrectly used an escaped hash (`\#{...}`) in string interpolations, which prevented the nutritional values from being rendered. This has been corrected by removing the backslash. 2. **Adds AFCD Name:** The view now displays the `food_name` from the Australian Food Classification Data to provide more context to the user. --- app/views/crops/_nutritional_data.html.haml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/crops/_nutritional_data.html.haml b/app/views/crops/_nutritional_data.html.haml index 51be27e73..a9d3135dc 100644 --- a/app/views/crops/_nutritional_data.html.haml +++ b/app/views/crops/_nutritional_data.html.haml @@ -3,36 +3,36 @@ .card .card-body %h4.card-title Nutritional Data - %p.card-text A summary of nutritional data per 100g. + %p.card-text A summary of nutritional data per 100g for #{data.food_name}. %table.table.table-sm.table-borderless %tbody - if data.energy_with_dietary_fibre_equated_kj.to_f > 0 %tr %th Energy - %td= "\#{data.energy_with_dietary_fibre_equated_kj.to_f.round(1)} kJ" + %td= "#{data.energy_with_dietary_fibre_equated_kj.to_f.round(1)} kJ" - if data.protein_g.to_f > 0 %tr %th Protein - %td= "\#{data.protein_g.to_f.round(1)} g" + %td= "#{data.protein_g.to_f.round(1)} g" - if data.fat_total_g.to_f > 0 %tr %th Fat, total - %td= "\#{data.fat_total_g.to_f.round(1)} g" + %td= "#{data.fat_total_g.to_f.round(1)} g" - if data.available_carbohydrate_with_sugar_alcohols_g.to_f > 0 %tr %th Carbohydrate - %td= "\#{data.available_carbohydrate_with_sugar_alcohols_g.to_f.round(1)} g" + %td= "#{data.available_carbohydrate_with_sugar_alcohols_g.to_f.round(1)} g" - if data.total_sugars_g.to_f > 0 %tr %th - Sugars - %td= "\#{data.total_sugars_g.to_f.round(1)} g" + %td= "#{data.total_sugars_g.to_f.round(1)} g" - if data.total_dietary_fibre_g.to_f > 0 %tr %th Fibre - %td= "\#{data.total_dietary_fibre_g.to_f.round(1)} g" + %td= "#{data.total_dietary_fibre_g.to_f.round(1)} g" - if data.sodium_na_mg.to_f > 0 %tr %th Sodium - %td= "\#{data.sodium_na_mg.to_f.round(1)} mg" + %td= "#{data.sodium_na_mg.to_f.round(1)} mg" .card-footer = link_to "See more", "https://afcd.foodstandards.gov.au/fooddetails.aspx?PFKID=#{data.public_food_key}", target: "_blank", rel: "noopener noreferrer"