Change city_lookup to load all configured cities#68
Change city_lookup to load all configured cities#68duduribeiro wants to merge 1 commit intothecodecrate:mainfrom
Conversation
Closes thecodecrate#67 There is a problem with city_lookup. It only loads the cities for the first statue you called `cities` on. This is because `cities` memoizes all the cities for the country, but `city_lookup` only loads the cities for the state, and doesn't get called again for the other states. Ex: having the following `db/cities-lookup.yml`: ```yaml BR: GO: "Mutunópolis": "Mutunópolis" ``` If I load first cities for other state, it does not include this missing city: ```shell bin/rails c CS.cities(:sp, :br) # loading another state first CS.cities(:go, :br).include?("Mutunópolis") ``` returned false but it should be true. If I load this state first, it works correctly ```shell bin/rails c CS.cities(:go, :br).include?("Mutunópolis") ``` This commit changes `city_lookup` to load all the cities for the country.
|
@duduribeiro Hello 👋 Any updates on this^? We are facing a similar issue when trying to add cities using the |
|
hey @viviancan 👋 I'm not a maintainer of the repo, so I can't merge. What you can do is use this commit (like I'm doing in my app). You can add this on your Gemfile and check if it works on your case. It worked for me |
@duduribeiro Thank you for the tip 😄 Hopefully there will be some feedback on this issue soon! |
City-state has two problemas that is prohibiting using the gem on most recente ruby versions: - thecodecrate#68 - thecodecrate#66 This commit applies these fixes
Hey @viviancan 👋 I tried to reach @loureirorg about these but without success. I created a new gem https://github.com/duduribeiro/civitas https://rubygems.org/gems/civitas which contains these fixes and I will try to apply future fixes as well, since I use these gem. It is an easy drop-in replacement for |
Closes #67
There is a problem with city_lookup. It only loads the cities for the first statue you called
citieson. This is becausecitiesmemoizes all the cities for the country, butcity_lookuponly loads the cities for the state, and doesn't get called again for the other states.Ex:
having the following
db/cities-lookup.yml:If I load first cities for other state, it does not include this missing city:
returned false but it should be true.
If I load this state first, it works correctly
This commit changes
city_lookupto load all the cities for the country.