All threads / How do I create localized dropdowns with countires and cities?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I create localized dropdowns with countires and cities?

Kajzer asked in General

Hi,

I want to create a webpage (localized) with venues that have address (geocoded) and than search them by dropdowns/search field(autocomplete) in the area of X miles/km around location, so that I can have friendly url for those searches. I have seen few approaches to search/dropdowns as well as how the urls look like. For example urls were structured like that:

  • somewebsite.com/venuetype-country-city
  • somewebsite.com/venuetype/

And searches were made usualy with dropdowns, so there is possibility to choose venu type, country and city or with autocomplete that hits some url endpoint on the website to retrive cities/countries (probably to save on google place autocomplete). I have found many gems that could help me with this like city-state gem. The only problem with that is that it is not localized so there is no translations. On the other hand im using geocoder gem to geoccode address provided by the venu in profile settings andd have doubts if it will work with city-state gem values. As for translations I found that geocoder returns only one version of language per request. I was thinking about something like geonames_dump which should have alternate name for countries/cities and I would be able to get names of locations from my endpoint (no hits to external api). So my question is how to go about creating something like that? Maybe there is a simple way that I just missed and I'm overthinking it all? Any suggestions will be greatly appreciated.

Thank you so much! Now everything it's clear!

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 38,558+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.