From 969aac942846cd047bbb0131e900b46ddc69a4c5 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 15 May 2019 22:41:41 +0200 Subject: [PATCH] handle missing country code. #257 --- app/models/funder.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/funder.rb b/app/models/funder.rb index 8a2971215..b8a2f63f3 100644 --- a/app/models/funder.rb +++ b/app/models/funder.rb @@ -44,8 +44,9 @@ def self.query(query, options={}) def self.parse_message(id: nil, message: nil) if message["location"].present? c = ISO3166::Country.find_country_by_name(message["location"]) + code = c.alpha2.present? ? c.alpha2 : nil country = { - "code" => c.alpha2, + "code" => code, "name" => message["location"] } else