You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the countries list to get a country name using it's ISO3166 code.
This is done easily using the :number attribute of a country.
Example: Countries.filter_by(:number, "250")
This works great in most cases, given that the code is a string. However, sometimes the :number attribute is stored as an integer, for example country with ISO code 48 (Bahrain) or Bolivia. For those countries I need tu use this: Countries.filter_by(:number, 48)
Obviously, this isn't a major issue as I'm just bypassing this by using a map function on all countries to convert to either string or an integer. Just converting all codes solves this problem.
But I thought I'd share this issue as it would make the list cleaner and debugging less confusing when using country ISO3166 codes to just use the same type for all countries, whether string or int.
Thanks!
The text was updated successfully, but these errors were encountered:
I am using the countries list to get a country name using it's ISO3166 code.
This is done easily using the
:number
attribute of a country.Example:
Countries.filter_by(:number, "250")
This works great in most cases, given that the code is a string. However, sometimes the
:number
attribute is stored as an integer, for example country with ISO code 48 (Bahrain) or Bolivia. For those countries I need tu use this:Countries.filter_by(:number, 48)
Obviously, this isn't a major issue as I'm just bypassing this by using a map function on all countries to convert to either string or an integer. Just converting all codes solves this problem.
But I thought I'd share this issue as it would make the list cleaner and debugging less confusing when using country ISO3166 codes to just use the same type for all countries, whether string or int.
Thanks!
The text was updated successfully, but these errors were encountered: