2

In my Rails 5 app, I have an Address model, which has Country Code and Region (state). I've done quite a bit of research, but I can't seem to find a current gem that will help me create a select dropdown for country that's populated with all the possible, then once I select a country, populates a second select dropdown for region that has all the regions of that country. None of the gems I've been directed to thus far have been updated recently, and some (like country_state_select) doesn't work at all in Rails 5.

Has anyone come up with an elegant solution for this problem in Rails 5 specifically?

Onikoroshi
  • 281
  • 4
  • 16
  • You could fetch the information from google places API, and then work with it, unfortunately never heard of a gem to handle everything in that regard. References: http://googlegeodevelopers.blogspot.com/2012/05/faster-address-entry-with-google-places.html https://developers.google.com/places/documentation/autocomplete – fabriciofreitag Apr 06 '17 at 05:13
  • Thank you for the response! Unfortunately the blog is almost 5 years old now, and the images don't work anymore. And, I don't see anything in the API that just lists countries and their regions. Just out of curiosity, when you're building a Rails 5 app and need an address form, what strategy do you use? – Onikoroshi Apr 06 '17 at 20:53
  • To be honest I never faced the same problem, but one thing is for sure, or either you use an external API and fetch all the values on the fly, or you keep this info on your on DB. I would look for an external API or something like that, since it's just static data. I googled it a bit, here are a few other related questions: http://stackoverflow.com/questions/36736195/how-to-get-list-of-all-countries-and-cities-in-rails http://stackoverflow.com/questions/26415195/best-way-to-dropdown-a-list-of-country-in-rails-4 – fabriciofreitag Apr 07 '17 at 02:27

0 Answers0