From 798f7f2bb9ecf922f9fbc14e34e145d8220fa7c2 Mon Sep 17 00:00:00 2001 From: Dave Bradford Date: Fri, 6 Oct 2023 15:29:52 -0600 Subject: [PATCH] Fix when country name is nil. --- Gemfile.lock | 3 ++- lib/country_select/tag_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3e31a7f..1d2b7d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - country_select (8.0.1) + country_select (8.0.2) countries (~> 5.0) GEM @@ -87,6 +87,7 @@ GEM PLATFORMS arm64-darwin-22 + ruby x86_64-darwin-22 x86_64-linux diff --git a/lib/country_select/tag_helper.rb b/lib/country_select/tag_helper.rb index 2a8872d..2d7f351 100644 --- a/lib/country_select/tag_helper.rb +++ b/lib/country_select/tag_helper.rb @@ -73,11 +73,11 @@ def country_options country_options_for(codes, sorted: sort) end - def country_options_for(country_codes, sorted: rue) + def country_options_for(country_codes, sorted: true) I18n.with_locale(locale) do country_list = country_codes.map { |code_or_name| get_formatted_country(code_or_name) } - country_list.sort_by! { |name, _| [I18n.transliterate(name), name] } if sorted + country_list.sort_by! { |name, _| [I18n.transliterate(name.to_s), name] } if sorted country_list end end