countries / country_select

Gemification of rails's country_select
https://country-select-demo.onrender.com
MIT License
704 stars 198 forks source link

Failure to render in last release #207

Open Nerian opened 2 years ago

Nerian commented 2 years ago

Hi,

Using country_select (8.0.0)

I believe something changed with the latest release because I get an error.

Screenshot 2022-07-07 at 10 25 11

f.input :country, include_blank: false

I believe this happens because if this change: https://github.com/countries/country_select/commit/981cd240ed46da7c418d73831ef4b02bdff3d915#diff-b3e24e44f4100d7ed00cce762b96b5459e6db4c269a3ed31f25c71d8fbade460R102

Notice that in the country list there is

 [nil, "Netherlands antilles"], [nil, "Cote divoire"]]

and that first value is what gets passed to the I18n.transliterate(name), name]. But because 'name' is null it raises.

I had to add this in order to fix it for the time being.

CountrySelect::DEFAULTS[:except] = ['NETHERLANDS ANTILLES', 'COTE DIVOIRE']
afdev82 commented 2 years ago

I have this error too! Any news about that?

henrik commented 2 years ago

FWIW it works fine here – country_select renders with "Netherlands Antilles".

Looks odd that your country_codes in the screenshot includes "NETHERLANDS ANTILLES" instead of its country code (AN). Out of curiosity, does this work for you in a console?

>> ISO3166::Country.search("AN")
=> #<ISO3166::Country:0x0000558171c49558 @country_data_or_code="AN", @data={"translations"=>{"sv"=>"Nederländska Antillerna", "en"=>"Netherlands Antilles", "de"=>"Niederländische Antillen", "es"=>"Antillas Neerlandesas"}, "alpha2"=>"AN"}>
Nerian commented 2 years ago
[1] pry(main)> ISO3166::Country.search("AN")
=> nil
countries (5.1.1)
country_select (8.0.0)
henrik commented 2 years ago

Ah, I'm on countries 5.0.0 and country_select 8.0.0.

olleolleolle commented 2 years ago
DEV 15:29:24 >> ISO3166::Country.search("AN")
=> #<ISO3166::Country:0x00005620073169d8
 @country_data_or_code="AN",
 @data=
  {"translations"=>
    {"sv"=>"Nederländska Antillerna",
     "en"=>"Netherlands Antilles",
     "de"=>"Niederländische Antillen",
     "es"=>"Antillas Neerlandesas"},
   "alpha2"=>"AN"}>

Looks good to me, I'm on countries 5.1.1 and country_select 8.0.0.

Nerian commented 2 years ago

@olleolleolle Are you sure you were running countries 5.1.1? Did you bundle exec rails c?

I still get nil even with countries 5.1.2

[3] pry(main)> ISO3166::Country.search("AN")
=> nil
pmor commented 1 year ago

Netherlands Antilles was dissolved in 2010 and is no longer a constituent country of the Netherlands, having been split into Bonaire, Saint Eustatius and Saba (BQ), Curaçao (CW) and Sint Maarten (SX), so ISO3166::Country.search("AN") should be nil.

As far as I can tell, the AN code was removed from the underlying countries gem in 2016, and 'COTE DIVOIRE' is mis-spelled, so I'm a bit puzzled with where that list of countries comes from.

zerobearing2 commented 1 year ago

Was having same error after upgrading to Rails 7.1 today, https://github.com/countries/country_select/pull/222 seems to fix it.

olleolleolle commented 9 months ago

https://github.com/countries/country_select/releases/tag/v8.0.3 contains the #222 PR.