From a950f603b2f709be6fb82a1781a17a181f7bf43b Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Fri, 20 Mar 2026 18:27:41 +0000 Subject: [PATCH] CLDC-4340: Account for nil location name on location select use postcode as a fallback, which should never be nil --- app/models/form/lettings/questions/location_id.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index 80e34aac0..ee51688f1 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -31,8 +31,9 @@ class Form::Lettings::Questions::LocationId < ::Form::Question scheme_location_ids = lettings_log.scheme.locations.visible.confirmed.pluck(:id) answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) } .sort_by { |_, v| - name = v["hint"].match(/[a-zA-Z].*/).to_s - number = v["hint"].match(/\d+/).to_s.to_i + name_or_postcode = v["hint"] || v["value"] # name can be nil, postcode is never nil + name = name_or_postcode.match(/[a-zA-Z].*/).to_s + number = name_or_postcode.match(/\d+/).to_s.to_i [name, number] }.to_h end